Previously in my Magento store I had set the Qty for Item's Status to Become Out of Stock in the inventory to 5 so that if the quantity of the products reaches to 5 or below it should show as out of stock and it was working properly. Now I want the quantity to be displayed according to the exact number and hence I changed the value of Qty for Item's Status to Become Out of Stock from 5 to 0. But even after changing the products are still showing out of stock when the count reaches 5. I have reindexed all the data and I have even cleared the cache after changing the value. Kindly let me know what should I do to enable the products to show in stock even if the count reaches 5 or below.
Magento – Products still showing out of stock
magento-1out-of-stockproductquantitystock-status
Related Solutions
Check your system configuration for values set at different store/website levels that might override your global settings.
Check your individual products for configuration that might override your system configuration levels.
Try setting a quantity to 1, purchasing a product, and checking is things are marked out of stock. (i.e. the products you see may have been explicitly set to be in stock with a quantity of 0 before you made your change. If this is the case and the system is otherwise behaving, I'd try setting those products to be out of stock manually)
I ran a grep for "setIsInStock" and there are only a few places where this is set:
What I've found in Mage_CatalogInventory_Model_Stock
and Mage_CatalogInventory_Model_Stock_Item
is, that there is a check the functions of these classes for the minimum quantity of the product.
The backend setting for this (on the product edit page) is "Qty for Item's Status to Become Out of Stock".
This is for example the code in Mage_CatalogInventory_Model_Stock_Item
:
/**
* Before save prepare process
*
* @return Mage_CatalogInventory_Model_Stock_Item
*/
protected function _beforeSave()
{
//...
$isQty = Mage::helper('catalogInventory')->isQty($typeId);
if ($isQty) {
if (!$this->verifyStock()) {
$this->setIsInStock(false)
->setStockStatusChangedAutomaticallyFlag(true);
}
//.....
} else {
$this->setQty(0);
}
return $this;
}
and verifyStock which also checks for the minimum quantity: $qty <= $this->getMinQty()
/**
* Chceck if item should be in stock or out of stock based on $qty param of existing item qty
*
* @param float|null $qty
* @return bool true - item in stock | false - item out of stock
*/
public function verifyStock($qty = null)
{
if ($qty === null) {
$qty = $this->getQty();
}
if ($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_NO && $qty <= $this->getMinQty()) {
return false;
}
return true;
}
Possible solution:
My guess is, that you have a minimum quantity set which is higher than "1".
Update:
As tested in the comments below, the is_in_stock
value is not set back when updating a product in the backend.
It seems the only place where a product is set into stock by default is backItemQty()
method in Mage_CatalogInventory_Model_Stock
when an order is cancelled/returned.
Best Answer
Ref.: http://docs.magento.com/m1/ce/user_guide/catalog/inventory-manage-stock.html