I am working on a store with thousands of products. I have noticed that when product Quantity is zero (or manually turned to Zero) the Stock Availability goes 'Out of Stock' however when we update the product Quantity to number greater then zero like 10,15 or 200 the 'Stock Availability' stays 'Out of Stock' unless and until manually changed to 'In Stock' so that the product appears on frontend. I want the 'Stock Availability' to Auto turned to 'In Stock' as we update the Quantity to number greater then Zero. The Quantity in my case gets its values from the store inventory software we don't change it manually.

  • how you update the stock quantity? manually or by script Commented Jul 24, 2015 at 12:59
  • Until now we were doing it through a php script.But we are about to purchase an extension which will sync products according to our stores inventory. Commented Jul 24, 2015 at 13:33
  • In script itself, you can change the stock availabillity. Did you tried that? Commented Jul 25, 2015 at 1:59
  • Yeah i guess theres an option in script.But my store owners want it to be predefined without having to change it again and again. Commented Jul 25, 2015 at 3:51

1 Answer 1


you can use Magento event catalog_product_save_after.

write this in your config.xml file


Create an observer method changeStockStatus() at below location your_module/Model/Observer.php that does the following on event catalog_product_save_after.

public function changeStockStatus($observer) {
    $product = $observer->getProduct();
    $stockData = $product->getStockData();

    if ( $product && $stockData['qty'] > 0) {
        $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getEntityId()); // Load the stock for this product
        $stock->setData('is_in_stock', 1); // Set the Product to InStock                               
        $stock->save(); // Save
  • Manashvi can you tell where do i have to place this method in magento files? I am just a newbie Commented Jul 24, 2015 at 13:41
  • check my edited answer Commented Jul 24, 2015 at 13:47
  • Hello Mashavi i tried following as you wrote but its not working.i cleared my cache after making the module with your files and then tried it on localhost by turning quantity of one of product to zero,then increasing it so it shows on frontend but it does not. Commented Jul 24, 2015 at 19:38
  • Please also note that the observer.php gives error on line 3,could that be the issue? Commented Jul 24, 2015 at 19:41
  • Hi, this script will work when you manually change the stock of the product or if any custom script updates the stock. Also can you let me know what is the error in the observer.php Commented Jul 28, 2015 at 11:25

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.