Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0bd75c8

Browse files
nmalevanecgelanivishal
authored andcommitted
NGCOM-2997: #4942 and bundle checkbox bug #15905. Fix functional and…
1 parent 8050d50 commit 0bd75c8

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

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

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Bundle\Model\Option;
99
use Magento\Catalog\Model\Product;
10+
use Magento\Framework\DataObject;
1011

1112
/**
1213
* Catalog bundle product info block
@@ -170,7 +171,7 @@ public function getJsonConfig()
170171

171172
$defaultValues = [];
172173
$preConfiguredFlag = $currentProduct->hasPreconfiguredValues();
173-
/** @var \Magento\Framework\DataObject|null $preConfiguredValues */
174+
/** @var DataObject|null $preConfiguredValues */
174175
$preConfiguredValues = $preConfiguredFlag ? $currentProduct->getPreconfiguredValues() : null;
175176

176177
$position = 0;
@@ -193,23 +194,13 @@ public function getJsonConfig()
193194
$options[$optionId]['selections'][$configValue]['qty'] = $configQty;
194195
}
195196
}
196-
197-
$preConfiguredQtys = $preConfiguredValues->getData("bundle_option_qty/${optionId}") ?? [];
198-
$selections = $options[$optionId]['selections'];
199-
array_walk($selections, function (&$selection, $selectionId) use ($preConfiguredQtys) {
200-
if (is_array($preConfiguredQtys) && isset($preConfiguredQtys[$selectionId])) {
201-
$selection['qty'] = $preConfiguredQtys[$selectionId];
202-
} else if ((int)$preConfiguredQtys > 0) {
203-
$selection['qty'] = $preConfiguredQtys;
204-
}
205-
});
206-
$options[$optionId]['selections'] = $selections;
197+
$options = $this->processOptions($optionId, $options, $preConfiguredValues);
207198
}
208199
$position++;
209200
}
210201
$config = $this->getConfigData($currentProduct, $options);
211202

212-
$configObj = new \Magento\Framework\DataObject(
203+
$configObj = new DataObject(
213204
[
214205
'config' => $config,
215206
]
@@ -414,4 +405,30 @@ private function getConfigData(Product $product, array $options)
414405
];
415406
return $config;
416407
}
408+
409+
/**
410+
* Set preconfigured quantities and selections to options.
411+
*
412+
* @param string $optionId
413+
* @param array $options
414+
* @param DataObject $preConfiguredValues
415+
* @return array
416+
*/
417+
private function processOptions(string $optionId, array $options, DataObject $preConfiguredValues)
418+
{
419+
$preConfiguredQtys = $preConfiguredValues->getData("bundle_option_qty/${optionId}") ?? [];
420+
$selections = $options[$optionId]['selections'];
421+
array_walk($selections, function (&$selection, $selectionId) use ($preConfiguredQtys) {
422+
if (is_array($preConfiguredQtys) && isset($preConfiguredQtys[$selectionId])) {
423+
$selection['qty'] = $preConfiguredQtys[$selectionId];
424+
} else {
425+
if ((int)$preConfiguredQtys > 0) {
426+
$selection['qty'] = $preConfiguredQtys;
427+
}
428+
}
429+
});
430+
$options[$optionId]['selections'] = $selections;
431+
432+
return $options;
433+
}
417434
}

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@
9494
<click stepKey="clickEdit" selector="{{CheckoutCartProductSection.nthEditButton('1')}}"/>
9595
<waitForPageLoad stepKey="waitForStorefront2"/>
9696

97-
<!-- Choose both of the options on the storefront -->
98-
<click stepKey="selectFirstBundleOption2" selector="{{StorefrontBundledSection.nthBundledOption('1','1')}}"/>
99-
<click stepKey="selectSecondBundleOption2" selector="{{StorefrontBundledSection.nthBundledOption('1','2')}}"/>
97+
<!-- Check second one option to choose both of the options on the storefront -->
98+
<click selector="{{StorefrontBundledSection.bundleOption('1','2')}}" stepKey="selectSecondBundleOption2"/>
10099

101100
<waitForPageLoad stepKey="waitForPriceUpdate3"/>
102101
<see stepKey="seeDoublePrice" selector="{{StorefrontBundledSection.configuredPrice}}" userInput="2,460.00"/>

0 commit comments

Comments
 (0)