Originally Posted by
jmberman
Once I re-enable a category, I seem to have to re-enable all the products within it individually, is there a faster way so where I enable the category it re-enables all the products too?
I thought that was something presented to the user when re-enabling the category, much like when disabling the category. It might be something that has recently been added to ZC 1.5.7, but regardless the categories template has been rewritten to hide the selection button when on a mobile device (small screen resolution which could also occur if the screen width for the browser is shrunk down) and my current install hasn't been modified to support seeing the buttons and therefore I'm having difficulty confirming that additional operation.
Now, it is possible to execute a sql query to cause this, but playing with database data manually comes with its own concerns...
There are two queries that come to mind. One is to enable all product that are "rooted" in the category, meaning the master_categories_id is that of the category being enabled. The other is any product that is to be visible in the category (this includes those with a master_categories_id of as well as those linked to the category being re-enabled). Taking a step back further though, it is possible that a category has other sub-categories that were disabled which also may need to be re-enabled, but that would be yet another set of queries compared to the two I would generate from the above.
So, the one where the product are rooted in the category. First for either of these, need to identify the categories id which is the number to the left of the categories name.
Code:
UPDATE products SET products_status = 1 WHERE master_categories_id = N AND products_status = 0;
Where N is the value of the categories_id that has the product to be enabled.
The second which affects linked product as well:
Code:
UPDATE products p SET p.products_status = 1 WHERE p.products_id IN (SELECT p2c.products_id FROM products_to_categories p2c WHERE p2c.categories_id = N) AND p.products_status = 0;
Again where N is the categories_id as previously discovered.
Bookmarks