Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

mass clean products options and attributes


sinopia

Recommended Posts

Hi everyone,

I have a old attributes (a lot) that I won't use anymore. Removing one-per-one for each products would take me a few days, while trying at the admin panel removing it shows me this: This option has products and values linked to it - it is not safe to delete it.

My question is this is safe at all, just want to remove the attributes linked to products and remove those product option as well. I also have thought about a mysql query to remove all from products_attributes table that I don't need anymore and also do a clean on database.

I have something like 131705 records on products_attributes a lot of them are inactive.

Also if I remove directly the product option will remove their respective option values as well?

Link to comment
Share on other sites

I'm asking this because I'm doing a left box to filter the products by attributes and this show the old one, otherwise I have to filter the desired ones.. but if I clean this probably will also help the performance.

Link to comment
Share on other sites

Try this,

 

Products Attributes I belive uses 3 tables in the db,  you can either export these and clean them up and suck whats left back into the db

or if they are all to be removed just truncate those tables. What ever you do backup first just to be safe.

 

Link to comment
Share on other sites

Hi @JcMagpie

Is there a possibility of to remove only certain attributes? They're really old on the same table of the current used. So truncate won't work for me. This store have more than 2000 products each one with around 10 product options and their respective option values.

I have also a few olds that aren't necessary anymore. That addons seems to be good but in my case just need to remove some specifics. My question is, if it's safe to delete them using products_attributes.php which shows: This option has products and values linked to it - it is not safe to delete it, or should I use mysql to delete all except the ones I currently use.

I usually do backups before doing anything, thanks.

Link to comment
Share on other sites

I'm not sure I understand what your issues is, you can do it in admin or with the add-on or by exporting to csv and cleaning it.

Products Attributes can be deleated without affecting Options or Values.

Deleating Options is only safe if the value linked to them is no longer used.

say Color has values  red, blue, green , you must remove those values from color before you remove color as values can be shared by many options!

 

Link to comment
Share on other sites

@JcMagpie I'll try to deleted them through products_attributes.php, I just don't have sure about this "This option has products and values linked to it - it is not safe to delete it."

Beside the product option and the option values being removed, maybe the old orders that had this attributed selected would give a error when opening? 

Link to comment
Share on other sites

13 minutes ago, sinopia said:

This option has products and values linked to it - it is not safe to delete it."

This warning is given when the option is still beeing used by a attribute so you must make sure no attribute is still using the option

 

Link to comment
Share on other sites

4 minutes ago, JcMagpie said:

This warning is given when the option is still beeing used by a attribute so you must make sure no attribute is still using the option

That makes sense. But +2000 products open each one and disable all that options will take much time. I'll only delete directly the product option I want, that should be fine, right?

Link to comment
Share on other sites

Well... I couldn't edit the last post... I'll try to remove those through mysql ...

Product options to keep: 17, 18, 19, 20, 21, 22, 23, 24, 25. And options values from 126  to 218.

The issue now is that I got 131705 products attributes.. Already with the products that are currently offline.

I've take a lot at products_attributes.php and I could do something like this:

$option_id = array('17', '18', '19', '20', '21', '22', '23', '24', '25'); // Product Option
tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id NOT IN ( '" . implode( "', '" , $option_id ) . "' )";

//Also the products_attributes has those:
tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int)$value_id . "'");
tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . (int)$attribute_id . "'");

I'll try the addon "Easier Attributes" as you told.

Link to comment
Share on other sites

  • 9 months later...

is it possible can we make attributes unique. for example i have used color option name for many products with different color attributes values. suppose

product A color  (red, green, yello)

products B second option name with different color (orange, green)

product C second otion name with different color option name and diffrernt values (yello, orange, black)

is there any query i can remove the duplicate names of options and values. so in attribure manage it should looks
only one color attribute with values red, green, yello, orange, black.

 

if you understad please let me know or if further need modificaions or suggestions.

thanks

Link to comment
Share on other sites

Sorry, I may have misunderstood your description. Please ignore my post.

I never have duplicate options issue because I consider options, names and values as individual unrelated entries. When I assign an attribute to a product, I just choose and combine option+name+value into one attribute for that product.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...