How To Update Product Status (ENABLED/DISABLED) Programmatically In Magento?

Magneto Update Product Status (ENABLED/DISABLED) :- Sometimes we need to update product status programmatically in magento. In this blog we are going to study how to update product status enable and disable as per the discretion with programmatically syntax code and example.


Magento Set Product Status Enable Syntax:-

In the following code we have used product id and store id for enabling the respective product in Magento.

$productid=15;// product id which you want to change status;
$storeid=1 // your store id 0 is for default store id
Mage::getModel('catalog/product_status')->updateProductStatus($productid, 
$storeid, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);

The above example will set the product status as Enable.

Magento Set Product Status Disable Syntax:-

Similarly in the scenario for disabling products we also have to use product ID and store ID respectively.

$productId = 16;
$storeId = 1; 
Mage::getModel('catalog/product_status')->updateProductStatus($productId, 
$storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);

The above example will set the product status as disabled.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *