/** * Back stock item data when we cancel order items * * @param Varien_Object $item */ public function cancelItemSale(Varien_Object $item) { if (($productId = $item->getProductId()) && ($qty = $item->getQtyToShip())) { $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); if ($item->getStoreId()) { $stockItem->setStoreId($item->getStoreId()); } $stockItem->addQty($qty)->save(); } return $this; }