How can I detect when a product's inventory level reaches 0 or it's status is changed to "Out of Stock" by Magento (not necessarily by the user)? I looked for an event, but I don't see one. Is my only choice to override the Stock_Item model?
1 Answer
Look in app/code/core/Mage/CatalogInventory/Model/Stock/Item.php
and notice that the $_eventPrefix is set to cataloginventory_stock_item
. That means that you can use the generic Object Saving events detailed in this blog post to register an Observer, e.g. cataloginventory_stock_item_save_after
and inspect the values of the object.
You will almost never need to override the model when you use the generic events.
-
3@Benubird Here's the link via archive.org: web.archive.org/web/20101020121221/http://masteringmagento.com/… Jun 6, 2013 at 21:50