Skip to content

Commit 4b57f6f

Browse files
MAGETWO-94268: [2.3] Bundle summary is not sorted by Bundle Item Position but by option_id
1 parent 5084541 commit 4b57f6f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView
5656
*/
5757
private $catalogRuleProcessor;
5858

59+
/**
60+
* @var array
61+
*/
62+
private $optionsPosition = [];
63+
5964
/**
6065
* @param \Magento\Catalog\Block\Product\Context $context
6166
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -172,6 +177,7 @@ public function getJsonConfig()
172177
}
173178
$optionId = $optionItem->getId();
174179
$options[$optionId] = $this->getOptionItemData($optionItem, $currentProduct, $position);
180+
$this->optionsPosition[$position] = $optionId;
175181

176182
// Add attribute default value (if set)
177183
if ($preConfiguredFlag) {
@@ -370,6 +376,7 @@ private function getConfigData(Product $product, array $options)
370376
$config = [
371377
'options' => $options,
372378
'selected' => $this->selectedOptions,
379+
'positions' => $this->optionsPosition,
373380
'bundleId' => $product->getId(),
374381
'priceFormat' => $this->localeFormat->getPriceFormat(),
375382
'prices' => [

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ public function testGetJsonConfigFixedPriceBundle()
280280
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
281281
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
282282
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
283+
$this->assertEquals([1], $jsonConfig['positions']);
283284
}
284285

285286
/**

app/code/Magento/Bundle/view/frontend/web/js/product-summary.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ define([
5656

5757
// Clear Summary box
5858
this.element.html('');
59-
60-
$.each(this.cache.currentElement.selected, $.proxy(this._renderOption, this));
59+
this.cache.currentElement.positions.forEach(function (optionId) {
60+
this._renderOption(optionId, this.cache.currentElement.selected[optionId]);
61+
}, this);
6162
this.element
6263
.parents(this.options.bundleSummaryContainer)
6364
.toggleClass('empty', !this.cache.currentElementCount); // Zero elements equal '.empty' container

0 commit comments

Comments
 (0)