Question

Product's Stock Status doesn't change when quantity drops below threshold in CE1.9.1...For starters, I've confirmed my config settings for all scopes, and they are all set as follows,

  • Manage Stock : Yes
  • Qty for Item's Status to Become Out of Stock : 4
  • Backorders : No Backorders

I've also confirmed that indexes are rebuilt, and I also reindexed manually to see if it would fix the bad products but they stay in stock. Each night, a cron job runs that updates the products through the magento api, then refreshes the cache and rebuilds all indexes. The desired effect is that if any product has stock lower than 4, it will remove the "Add to Cart" button. This is true of many products, they lose the button and all is good. But some products keep the "Add to Cart" button, and when I try to add them to the cart it won't allow it. So the cart realizes that I shouldn't be able to order it. So I'm not worried that someone will buy it, but I don't like seeing the warning when the button could just go away.

When I find one, I'll refresh the caches, rebuild the indexes, and then refresh the product page. Quantity 2, threshold 4, in stock! Button remains, but can't add to cart. Then I will go into the product in the admin interface, save it without making any changes, and it goes out of stock. Again, I don't need to do this to every product with quantity under 4, just some. It seems like something special happens when I save it in the interface, that doesn't happen when I save it using the api, refresh cache, and reindex.

I'm considering running another script after my cron job that will look for anything in cataloginventory_stock_status with qty<4, and setting those stock_status values to 0. This appears to work, even without rebuilding indexes/cache, but I don't like quirks especially when only some products are affected. And I've put considerable time into speeding up the api so that I wouldn't have to do hackish things like this. Anyone run into this and know what's up?

Was it helpful?

Solution

I solved this, but not elegantly. The interface will switch cataloginventory_stock_item.is_in_stock from 1 to 0, but the api will not, regardless of refreshing caches and reindexing. So now my cron job also goes into the database and sets cataloginventory_stock_item.is_in_stock to 0 or 1, and that has solved the problem. Not pretty, but at least customers stop seeing Add to Cart buttons that when clicked inform them of insufficient stock to add 1 to cart.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top