diff --git a/vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Save.php index 301efe26fc52a..450e9a5123078 100644 --- a/vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Save.php +++ b/vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Save.php @@ -1,7 +1,7 @@ getOrderItem()->getParentItemId()) { + if ($this->shouldSkipQuantityAccumulation($item)) { + continue; + } if (empty($parentQuantities[$parentId])) { $parentQuantities[$parentId] = $item->getQty(); } else { @@ -171,4 +180,21 @@ private function adjustCreditMemoItemQuantities(Creditmemo $creditMemo): void } } } + + /** + * Check if the quantity adjustment should be skipped + * + * @param Item $item + * @return bool + */ + private function shouldSkipQuantityAccumulation(Item $item): bool + { + $parentOrderItem = $item->getOrderItem()->getParentItem(); + if (!$parentOrderItem || $parentOrderItem->getProductType() !== Type::TYPE_BUNDLE) { + return false; + } + $parentOptions = $parentOrderItem->getProductOptions(); + return isset($parentOptions['product_calculations']) && + $parentOptions['product_calculations'] === AbstractType::CALCULATE_PARENT; + } }