From 81e0d5fd4010f6b4915c204439376edcd1e63783 Mon Sep 17 00:00:00 2001 From: Rihards Abolins Date: Wed, 13 Oct 2021 09:11:17 +0300 Subject: [PATCH] [3541] Bundle option qty --- src/Model/Quote/Item/Processor.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Model/Quote/Item/Processor.php b/src/Model/Quote/Item/Processor.php index 35890a6..a176ed7 100644 --- a/src/Model/Quote/Item/Processor.php +++ b/src/Model/Quote/Item/Processor.php @@ -18,6 +18,7 @@ use Magento\Framework\DataObject; use Magento\Quote\Api\Data\CartItemInterface; use Magento\Quote\Model\Quote\Item; +use Magento\Catalog\Model\Product\Type as ProductType; class Processor extends SourceProcessor { @@ -37,7 +38,18 @@ public function prepare(Item $item, DataObject $request, Product $candidate): vo if ($request->getResetCount() && !$candidate->getStickWithinParent() && $item->getId() == $request->getId()) { $item->setData(CartItemInterface::KEY_QTY, 0); } - $item->addQty($candidate->getCartQty()); + + $parent = $item->getParentItem(); + + if ($candidate->getTypeId() !== ProductType::TYPE_BUNDLE + && $parent + && $parent->getProductType() === ProductType::TYPE_BUNDLE + ) { + $item->setQty($candidate->getCartQty()); + } else { + $item->addQty($candidate->getCartQty()); + } + if (!$item->getParentItem() || $item->getParentItem()->isChildrenCalculated()) { $item->setPrice($candidate->getFinalPrice());