Skip to content

Commit f597e73

Browse files
ENGCOM-2997: #4942 and bundle checkbox bug #15905
- Merge Pull Request #15905 from JosephMaxwell/magento2:patch-2 - Merged commits: 1. c05ac4c 2. 076bb60 3. e35a9b1
2 parents 50a4da0 + e35a9b1 commit f597e73

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ public function getJsonConfig()
185185
if ($configValue) {
186186
$defaultValues[$optionId] = $configValue;
187187
}
188+
189+
$preConfiguredQtys = $preConfiguredValues->getData("bundle_option_qty/${optionId}") ?? [];
190+
$selections = $options[$optionId]['selections'];
191+
array_walk($selections, function (&$selection, $selectionId) use ($preConfiguredQtys) {
192+
if (is_array($preConfiguredQtys) && isset($preConfiguredQtys[$selectionId])) {
193+
$selection['qty'] = $preConfiguredQtys[$selectionId];
194+
} else if ((int)$preConfiguredQtys > 0) {
195+
$selection['qty'] = $preConfiguredQtys;
196+
}
197+
});
198+
$options[$optionId]['selections'] = $selections;
188199
}
189200
$position++;
190201
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ protected function _getSelectedOptions()
169169
*/
170170
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
171171
{
172-
if ($selectionId && $option->getSelectionById($selectionId)) {
172+
if (is_array($selectionId)) {
173+
$this->_selectedOptions = $selectionId;
174+
} else if ($selectionId && $option->getSelectionById($selectionId)) {
173175
$this->_selectedOptions = $selectionId;
174176
} elseif (!$option->getRequired()) {
175177
$this->_selectedOptions = 'None';

0 commit comments

Comments
 (0)