Jump to content

Disable (not delete) products in bulk by code


hakeryk2

Recommended Posts

Hello community,

 

I have a question - I have like 500 products to disable (not delete) - I still want to have them in the shop but 

EDIT (SOLVED)

 

Nevermind, kinda easy xD

$products_to_disable = Db::getInstance()->executeS('
    SELECT id_product FROM ps_product WHERE available_for_order = 0 AND date_upd < "2017-05-01 00:00:00"
');

foreach ($products_to_disable as $product) {
    $p = new ProductCore($product['id_product']);

    $p->active = false;
    $p->save();

    echo 'Disabled '.ProductCore::getProductName($p->id).'<br>';
}
Edited by hakeryk2 (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...