The Inventory Stock is decreasing even if the customer cancels their order
I handled this scenerio by following way
1) got the order by order id
2) for each order items updated the quantity before the cancel operation ie i just previously added the item quantity to item that is reducing on
my order cancellation.
i created this function
public function updateInventory($order_id)
$order = Mage::getModel(’sales/order’)->loadByIncrementId($order_id);
$items = $order->getAllItems();
foreach ($items as $itemId => $item)
$ordered_quantity = $item->getQtyToInvoice();
$product = Mage::getModel(’catalog/product’)->load($item->getProductId());
$qtyStock = Mage::getModel(’cataloginventory/stock_item’)->loadByProduct($product->getId())->getQty();
$stockData = $product->getStockItem();
and call this function where you are handling the cancellation operation like
In other words,
magento paypal has this bug that it decreases the inventory even if order is cancelled
for that i got the order item’s quantity and when the order is cancelled then before the
inventory is decreased i increased the same quantity of that item in inventory.
so after reducing the inventory my item quantity remains the same.
if product x quantity =6
then first increase it according to order quantity before transaction is saved
then the paypal order cancellation save do this
so product quantity remains the same.
hope this will help you.
I hope this will be helpful.Thanks Shailesh Thapa