Jump to content

Any way to disable all items in a specific category?


Recommended Posts

Howdy,

 

Title is pretty self explanatory. Is there any way I can select a category and disable all the items in that category? Or is there a way I can view al lthe items, check some boxes, and choose Disable all? The only button I see when I check the boxes is to delete them.

 

I don't want to have to manualyl disable every item individually so I need some other way to do that.

 

Thanks.

Link to comment
Share on other sites

Hi,

 

There is the SQL query for your task:

UPDATE `ps_product` SET active = 0 WHERE id_product IN (SELECT id_product FROM `ps_category_product` WHERE `id_category` = 2 GROUP BY id_product)

Notice that you need to use your prefix for tables (customPrefix_ instead of ps_) and your id_category (instead of "2")

 

Regards

Edited by Alexander Simonchik (see edit history)
Link to comment
Share on other sites

Try to create the php file with content:

 

<?php
require(dirname(__FILE__).'/config/config.inc.php');

$id_category = 2; //set ID of your category
$sql = 'UPDATE `'._DB_PREFIX_.'product` SET active = 0 WHERE id_product IN (SELECT id_product FROM `'._DB_PREFIX_.'category_product` WHERE `id_category` = '.(int)$id_category.' GROUP BY id_product)';
Db::getInstance()->Execute($sql);

 

And rut it (go to you_webstore/somename.php)

Edited by Alexander Simonchik (see edit history)
Link to comment
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
×
×
  • Create New...