Magento admin – Cancel order – back to stock qty with your custom qty

Magento admin – Cancel order – back to stock qty with your custom qty
In magento, once customer create the order. The order will be created from admin sales order section. In some scenario, admin want to cancel that order (with customer request). When admin cancel that item based on the product line item, the inventory will be back.
Ex:
SKU1 – Customer Ordered Qty is – 2
Currently Available inventory for SKU1 – 10
After order cancelled inventory will be back like
Available inventory for SKU1 – 12

Here i want to update my custom qty back to inventory means what we want to do.
Just have to follow below steps,
override below file into you local
htdocs\app\code\core\Mage\CatalogInventory\Model\Observer.php
my local is
htdocs\app\code\local\Jute\CatalogInventory\Model\Observer.php
Override below function and pass your custom qty to $qty variable.
public function cancelOrderItem($observer)
Mage::getSingleton(‘cataloginventory/stock’)->backItemQty($productId, $qty);

Cleare cache and checkt it. When admin cancel the order from admin section, your custom qty will back to stock.

………………………………………………………………………………………………………………………………………………………………..

Corner of Blog:

“Celebrate an Environmentally Safe Diwali”

………………………………………………………………………………………………………………………………………………………………..