Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 4 of 4
Poor handling of Paypal IPN data == Incorrect inventory == fake orders
 
Joy Thomas
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2011-01-19
Gurgaon
 

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();
$sku=$item->getSku();
$product = Mage::getModel(’catalog/product’)->load($item->getProductId());
$qtyStock = Mage::getModel(’cataloginventory/stock_item’)->loadByProduct($product->getId())->getQty();

$updated_inventory=$qtyStock+ $ordered_quantity;

$stockData = $product->getStockItem();
$stockData->setData(’qty’,$updated_inventory);
$stockData->save();

}
}

and call this function where you are handling the cancellation operation like

function cancelation($order_id)
{
$this->updateInventory($order_id);
$order->cancel()->save();
}

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.

For example

if product x quantity =6

then first increase it according to order quantity before transaction is saved

6+5=11
then the paypal order cancellation save do this

11-5=6

so product quantity remains the same.

thanks
hope this will help you.

I hope this will be helpful.Thanks Shailesh Thapa

 
Magento Community Magento Community
Magento Community
Magento Community
 
weiderj
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2012-02-28
 

hmm, code seems to be in order.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davinstewart
Jr. Member
 
Total Posts:  20
Joined:  2008-09-10
 

Are you frickin kidding me?  This is still an issue in Magento Community 1.7.1.

Just to be clear here, the solution is simple, decrement inventory when the order goes to status “Payment Received”.  WHY HASN’T THIS BEEN IMPLEMENTED?!

I can’t rely on my inventory tracking in Magento at all because of this ridiculous functionality.

Has ANYONE come up with a way to work around this?  It’s been over 4 YEARS!  Unbelievable.

Didn’t Paypal even buy Magento?  And there’s still this significant issue out there?  Come on!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 4 of 4