Fast bulk product status change with Magento

If you have a large catalogue, using some standard features are simply impractical to use. Recently, we needed to disable an entire range of products based on its SKU - via the backend, bulk status changing 5000 products will take hours, but fortunately SQL is a spot more lightweight.

In the code below (to be run via command line MySQL or phpMyAdmin), just replace %SKU% with your SKU identifier and use % as a wildcard or _ as a single character wildcard.

This will obviously apply to any other attribute, so just change the code as necessary.

enabled = 1
disabled = 2

UPDATE catalog_product_entity_int cpei, catalog_product_entity cpe
SET cpei.value = "2"
WHERE cpe.entity_id = cpei.entity_id
AND cpe.sku LIKE '%SKU%'
AND cpei.attribute_id = 273

quicksql

Disable by category

Another resource for disabling by category is

UPDATE catalog_product_entity_int cpei, catalog_product_entity cpe
SET value = '2'
WHERE cpe.entity_id = cpei.entity_id
AND attribute_id = "80"
AND cpe.category_ids = "%35%"
AND (cpe.category_ids LIKE "35,%" OR cpe.category_ids LIKE "%,35,%")

Remember to rebuild the category indexes

After the MySQL above has run - you'll need to let Magento take the reigns back a little to update the category indexes, this is quite straightforward, but a little time consuming.

Login to your admin and go to System > Cache Management, the select Rebuild Catalog Index

rebuildindex