I want change product stock when invoice is placed, not change when order is placed. Thanks everybody!
2 Answers
By default Magento provides this configuration for decrease stock from store > config > Catalog > Inventory > Stock Options
(Magento 2)
And to decrease the stock on Invoice you can use event sales_order_invoice_save_after.
Stock reduction is done in Mage_CatalogInventory_Model_Observer
. So to do it first we will have to stop quantity decrement. To do this go to method public function subtractQuoteInventory(Varien_Event_Observer $observer){}
in your rewritten observer and add below code
$items = $this->_getProductsQty($quote->getAllItems());
Mage::getSingleton('cataloginventory/stock')->revertProductsSale($items);
Now you will have to hook event sales_order_save_after
and in that observer you may reduce the stock
When does Magento decrement quantity This will help you in case you want to understand the decrement process
-
1Thank you, but this is magento 1, i want decrease stock when invoice is placed on magento 2 Commented Feb 22, 2018 at 8:23