0

I recently found out that I was having issues with refunding the qty of some Bundle products, and so I fell into the rabbit hole of trying to figure out why this was happening.

After testing in a fresh installation with Magento 1.9 sample pack, I found that the price type in the Bundle product was the culprit. It's refunding the full qty of the Bundle children when the price type is set to "Dynamic", but only refunding the Bundle's qty when it's "Fixed", why's that? Considering that the qty of children is always decremented from the stock, wouldn't it make sense to refund it back all the time?

After digging deeper I found this snippet which sets the product_calculations value on the product options field:

// app/code/core/Mage/Bundle/Model/Product/Type.php#L828-L835
/**
 * Product Prices calculations save
 */
if ($product->getPriceType()) {
    $optionArr['product_calculations'] = self::CALCULATE_PARENT;
} else {
    $optionArr['product_calculations'] = self::CALCULATE_CHILD;
}

This value is then used indirectly by the method below through Mage_Sales_Model_Order_Item::isDummy to determine whether to refund the full children qty or only 1:

// app/code/core/Mage/Sales/Model/Service/Order.php#L227-L230
if (isset($options['product_calculations']) &&
    $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
    return true;
}
// app/code/core/Mage/Sales/Model/Service/Order.php#L227-L230
if ($orderItem->isDummy()) {
    $qty = 1;
    $orderItem->setLockedDoShip(true);
} else {

Looking online it seems this issue is mostly thought of as a bug, but after looking at the source it seems to me it was intentional, but I can't get my head around why it works this way?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.