Question

Default behavior: When a product's quantity is 0 - the "out of stock" message is displayed. When the product becomes in stock (inventory updated by SAP), the "out of stock" message is disabled automatically.

Custom behavior: However, when a "custom out of stock" message is selected and the product becomes in stock, for whatever reason, the "custom out of stock" message is NOT disabled. This has to be done explicitly on the product.

--

After searching for a solution, one option is to buy/install an extension that handles "out of stock" products, but has anyone found a way to tackle this internally?

Was it helpful?

Solution

You need to set the is_in_stock flag during your update as '1' if qty>0. If this is not possible with your code then you will need to select all of your products with stock greater than zero and set them to is_in_stock=1. You can run this as a standalone script with no performance disadvantage to writing a module and putting that module on a cron job that will chime in after your update has gone through. Here is the pseudocode:

$stockCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()->addFieldToFilter('qty', array('gteq' => 1));

foreach($stockCollection as $item) {
    $item->setIsInStock(1)->save();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top