Skip to content

Commit da2828c

Browse files
committed
MC-41810: Cannot add bundle product with more than 1 checkbox option to the cart via Graphql
1 parent dea780c commit da2828c

File tree

1 file changed

+22
-1
lines changed
  • app/code/Magento/Bundle/Model/Product

1 file changed

+22
-1
lines changed

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,11 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
665665
$skipSaleableCheck = $this->_catalogProduct->getSkipSaleableCheck();
666666
$_appendAllSelections = (bool)$product->getSkipCheckRequiredOption() || $skipSaleableCheck;
667667

668-
$options = $buyRequest->getBundleOption();
668+
if ($buyRequest->getBundleOptionsData()) {
669+
$options = $this->getPreparedOptions($buyRequest->getBundleOptionsData());
670+
} else {
671+
$options = $buyRequest->getBundleOption();
672+
}
669673
if (is_array($options)) {
670674
$options = $this->recursiveIntval($options);
671675
$optionIds = array_keys($options);
@@ -1413,4 +1417,21 @@ protected function mergeSelectionsWithOptions($options, $selections)
14131417

14141418
return array_merge([], ...$selections);
14151419
}
1420+
1421+
/**
1422+
* Get prepared options with selection ids
1423+
*
1424+
* @param array $options
1425+
* @return array
1426+
*/
1427+
private function getPreparedOptions(array $options): array
1428+
{
1429+
foreach ($options as $optionId => $option) {
1430+
foreach ($option as $selectionId => $optionQty) {
1431+
$options[$optionId][$selectionId] = $selectionId;
1432+
}
1433+
}
1434+
1435+
return $options;
1436+
}
14161437
}

0 commit comments

Comments
 (0)