Jump to content
Sign in to follow this  
sinopia

mass clean products options and attributes

Recommended Posts

Posted (edited)

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?

Edited by sinopia

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Posted (edited)

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.

Edited by JcMagpie

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Posted (edited)

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!

Edited by JcMagpie

 

Share this post


Link to post
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? 

Share this post


Link to post
Share on other sites

I don't think this would affect orders history as it insert the products_option and value with their name and price... will make a backup and test.

Share this post


Link to post
Share on other sites

Otherwise instead output all products options/values to filter the products. I put them manually with the desired options.. As also to make a clean on the database..

Share this post


Link to post
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


 

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
Posted (edited)

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.

Edited by sinopia

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×