I'm trying to disable a product inside the catalog_product_save_before event.

I have tried this, but it doesn't seem to work:


I've also tried this, but I'm thinking this won't work because the product hasn't been added to the database yet.

$storeId = 0;
Mage::getModel('catalog/product_status')->updateProductStatus($product->getId(), $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);

How can I disable the product?

  • Can you add your config and observer code. Also is this code executing from the admin or frontend? Feb 13, 2015 at 15:23
  • Ah I have got it working now after shifting some code around.
    – Mex
    Feb 13, 2015 at 15:31

1 Answer 1


This is for all store view i think this is the dirty way to achieve this

    $allStores = Mage::app()->getStores();
    foreach ($allStores as $_eachStoreId => $val)
        $_storeId[] = Mage::app()->getStore($_eachStoreId)->getId();
        Mage::getModel('catalog/product_status')->updateProductStatus($product_id, $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
  • I have tried that code with both catalog_product_save_before and catalog_product_save_after, changing "$product_id=1;" to "$product_id=$product->getId();", but the product still gets added with an Enabled status.
    – Mex
    Feb 13, 2015 at 15:21
  • 1
    Oh I have shifted some other code around and it's working now, thanks a lot!
    – Mex
    Feb 13, 2015 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.