Skip to content

Commit 7952cfe

Browse files
committed
Merge remote-tracking branch 'origin/MC-35690' into 2.4-develop-pr119
2 parents cb1ab70 + 26e8eee commit 7952cfe

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ public function getJsonConfig()
184184
$configValue = $preConfiguredValues->getData('bundle_option/' . $optionId);
185185
if ($configValue) {
186186
$defaultValues[$optionId] = $configValue;
187-
$configQty = $preConfiguredValues->getData('bundle_option_qty/' . $optionId);
188-
if ($configQty) {
189-
$options[$optionId]['selections'][$configValue]['qty'] = $configQty;
190-
}
191187
}
192188
$options = $this->processOptions($optionId, $options, $preConfiguredValues);
193189
}

app/code/Magento/Bundle/Model/CartItemProcessor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151
}
5252

5353
/**
54-
* {@inheritdoc}
54+
* @inheritDoc
5555
*/
5656
public function convertToBuyRequest(CartItemInterface $cartItem)
5757
{
@@ -73,7 +73,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
7373
}
7474

7575
/**
76-
* {@inheritdoc}
76+
* @inheritDoc
7777
* @SuppressWarnings(PHPMD.NPathComplexity)
7878
*/
7979
public function processOptions(CartItemInterface $cartItem)
@@ -84,19 +84,21 @@ public function processOptions(CartItemInterface $cartItem)
8484
$productOptions = [];
8585
$bundleOptions = $cartItem->getBuyRequest()->getBundleOption();
8686
$bundleOptionsQty = $cartItem->getBuyRequest()->getBundleOptionQty();
87+
$bundleOptionsQty = is_array($bundleOptionsQty) ? $bundleOptionsQty : [];
8788
if (is_array($bundleOptions)) {
8889
foreach ($bundleOptions as $optionId => $optionSelections) {
8990
if (empty($optionSelections)) {
9091
continue;
9192
}
9293
$optionSelections = is_array($optionSelections) ? $optionSelections : [$optionSelections];
93-
$optionQty = isset($bundleOptionsQty[$optionId]) ? $bundleOptionsQty[$optionId] : 1;
9494

9595
/** @var \Magento\Bundle\Api\Data\BundleOptionInterface $productOption */
9696
$productOption = $this->bundleOptionFactory->create();
9797
$productOption->setOptionId($optionId);
9898
$productOption->setOptionSelections($optionSelections);
99-
$productOption->setOptionQty($optionQty);
99+
if (isset($bundleOptionsQty[$optionId])) {
100+
$productOption->setOptionQty($bundleOptionsQty[$optionId]);
101+
}
100102
$productOptions[] = $productOption;
101103
}
102104

app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ public function testGetJsonConfigFixedPriceBundleNoOption()
214214

215215
public function testGetJsonConfigFixedPriceBundle()
216216
{
217+
$optionId = 1;
218+
$optionQty = 2;
217219
$baseAmount = 123;
218220
$basePriceValue = 123123;
219221
$selections = [
@@ -230,7 +232,6 @@ public function testGetJsonConfigFixedPriceBundle()
230232
true
231233
)
232234
];
233-
234235
$bundleProductPrice = $this->getMockBuilder(Price::class)
235236
->disableOriginalConstructor()
236237
->setMethods(['getLowestPrice'])
@@ -246,10 +247,8 @@ public function testGetJsonConfigFixedPriceBundle()
246247
$this->bundleProductPriceFactory->expects($this->once())
247248
->method('create')
248249
->willReturn($bundleProductPrice);
250+
$options = [$this->createOption($optionId, 'Title `1', $selections)];
249251

250-
$options = [
251-
$this->createOption(1, 'Title `1', $selections),
252-
];
253252
$finalPriceMock = $this->getPriceMock(
254253
[
255254
'getPriceWithoutOption' => new DataObject(
@@ -289,7 +288,10 @@ public function testGetJsonConfigFixedPriceBundle()
289288
$preconfiguredValues = new DataObject(
290289
[
291290
'bundle_option' => [
292-
1 => 123123111,
291+
$optionId => [123123111],
292+
],
293+
'bundle_option_qty' => [
294+
$optionId => $optionQty,
293295
],
294296
]
295297
);
@@ -306,7 +308,8 @@ public function testGetJsonConfigFixedPriceBundle()
306308
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
307309
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
308310
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
309-
$this->assertEquals([1], $jsonConfig['positions']);
311+
$this->assertEquals([$optionId], $jsonConfig['positions']);
312+
$this->assertEquals($optionQty, $jsonConfig['options'][$optionId]['selections'][1123]['qty']);
310313
}
311314

312315
/**

0 commit comments

Comments
 (0)