Skip to content

Commit

Permalink
[bug-OpenMage#275] Creditmemo qty calculation error in Mage_CatalogIn…
Browse files Browse the repository at this point in the history
…ventory_Model_Observer

This bug was present begining in 1.7.0.2 and is still present in 1.9.3.3. This patch has been running in production for about 4 years without any issues.

Code was mis-calcuating the qty of simple items to put back in stock for bundle (and configurable) products.

For example if you had a Bundle X that contained 10 Widgets and the customer ordered 10 of the Bundle X (thus they ordered 100 Widgets),
the code previously would multiply twice when issuing a credit memo: When calling $item->getQty() on the Widget product Magento
would return 100, since that's how many exist in the order. It would then multiply that by the number of Bundle X in the order (10),
and would return 1000 items to the inventory for the Widget, instead of just 100.
  • Loading branch information
JonLaliberte authored and edannenberg committed Mar 20, 2018
1 parent ed206b3 commit 3f81fd8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/code/core/Mage/CatalogInventory/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ public function refundOrderInventory($observer)
$parentOrderId = $item->getOrderItem()->getParentItemId();
/* @var $parentItem Mage_Sales_Model_Order_Creditmemo_Item */
$parentItem = $parentOrderId ? $creditmemo->getItemByOrderId($parentOrderId) : false;
$qty = $parentItem ? ($parentItem->getQty() * $item->getQty()) : $item->getQty();
$qty = $item->getQty();
if (isset($items[$item->getProductId()])) {
$items[$item->getProductId()]['qty'] += $qty;
} else {
Expand Down

0 comments on commit 3f81fd8

Please sign in to comment.