From 53f59424c0b049e2f275c50bbced1fc9b42a6916 Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Wed, 6 Jun 2018 10:44:38 -0500 Subject: [PATCH] #4942: bundled products now retain customer selections when editing from cart --- .../Block/Catalog/Product/View/Type/Bundle.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 62a2fa1c47e1e..cab923da49215 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -193,6 +193,18 @@ public function getJsonConfig() $options[$optionId]['selections'][$configValue]['qty'] = $configQty; } } + + + $preConfiguredQtys = $preConfiguredValues->getData("bundle_option_qty/${optionId}") ?? []; + $selections = $options[$optionId]['selections']; + array_walk($selections, function(&$selection, $selectionId) use ($preConfiguredQtys) { + if (is_array($preConfiguredQtys) && isset($preConfiguredQtys[$selectionId])) { + $selection['qty'] = $preConfiguredQtys[$selectionId]; + } else if ((int)$preConfiguredQtys > 0) { + $selection['qty'] = $preConfiguredQtys; + } + }); + $options[$optionId]['selections'] = $selections; } $position++; }