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.