Tutorialsplane

Magento set product status programmatically


Magento set product status programmatically : Sometimes we need to update product status programmatically in magento. You can set product status enabled, disabled or other status. In this tutorial we are going to explain how to set product status programmatically in magento.


Magento set product status programmatically

You can update status as below

STATUS_ENABLED

You can set product status enabled as below –

Magento set product status programmatically: Enabled

$productId = 110;
$storeId = 1; //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 enabled.

STATUS_DISABLED

You can set product status disabled as below –

Magento set product status programmatically: Disabled

$productId = 110;
$storeId = 1; //store id
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.