Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect inventory change

Tags:

magento

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?

like image 882
Joe Constant Avatar asked Jun 11 '26 05:06

Joe Constant


1 Answers

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.

like image 58
Jonathan Day Avatar answered Jun 13 '26 23:06

Jonathan Day



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!