Skip to content

Commit d7a2d85

Browse files
Merge branch '2.4-develop-mainline' into mftf-gift-message
2 parents a1a91ae + aff512b commit d7a2d85

File tree

205 files changed

+7992
-6136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+7992
-6136
lines changed

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

Lines changed: 33 additions & 3 deletions
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);
@@ -732,7 +736,11 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
732736
if ((is_array($selections) && count($selections) > 0) || !$isStrictProcessMode) {
733737
$uniqueKey = [$product->getId()];
734738
$selectionIds = [];
735-
$qtys = $buyRequest->getBundleOptionQty();
739+
if ($buyRequest->getBundleOptionsData()) {
740+
$qtys = $buyRequest->getBundleOptionsData();
741+
} else {
742+
$qtys = $buyRequest->getBundleOptionQty();
743+
}
736744

737745
// Shuffle selection array by option position
738746
usort($selections, [$this, 'shakeSelections']);
@@ -1231,7 +1239,12 @@ public function getIdentities(\Magento\Catalog\Model\Product $product)
12311239
protected function getQty($selection, $qtys, $selectionOptionId)
12321240
{
12331241
if ($selection->getSelectionCanChangeQty() && isset($qtys[$selectionOptionId])) {
1234-
$qty = (float)$qtys[$selectionOptionId] > 0 ? $qtys[$selectionOptionId] : 1;
1242+
if (is_array($qtys[$selectionOptionId]) && isset($qtys[$selectionOptionId][$selection->getSelectionId()])) {
1243+
$selectionQty = $qtys[$selectionOptionId][$selection->getSelectionId()];
1244+
$qty = (float)$selectionQty > 0 ? $selectionQty : 1;
1245+
} else {
1246+
$qty = (float)$qtys[$selectionOptionId] > 0 ? $qtys[$selectionOptionId] : 1;
1247+
}
12351248
} else {
12361249
$qty = (float)$selection->getSelectionQty() ? $selection->getSelectionQty() : 1;
12371250
}
@@ -1404,4 +1417,21 @@ protected function mergeSelectionsWithOptions($options, $selections)
14041417

14051418
return array_merge([], ...$selections);
14061419
}
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+
}
14071437
}

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,16 @@ public function testPrepareForCartAdvancedWithoutOptions()
232232
/** @var MockObject|DataObject $buyRequest */
233233
$buyRequest = $this->getMockBuilder(DataObject::class)
234234
->setMethods(
235-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
235+
[
236+
'__wakeup',
237+
'getOptions',
238+
'getSuperProductConfig',
239+
'unsetData',
240+
'getData',
241+
'getQty',
242+
'getBundleOption',
243+
'getBundleOptionsData',
244+
]
236245
)
237246
->disableOriginalConstructor()
238247
->getMock();
@@ -342,7 +351,8 @@ public function testPrepareForCartAdvancedWithShoppingCart()
342351
'getData',
343352
'getQty',
344353
'getBundleOption',
345-
'getBundleOptionQty'
354+
'getBundleOptionQty',
355+
'getBundleOptionsData',
346356
]
347357
)
348358
->disableOriginalConstructor()
@@ -586,7 +596,8 @@ public function testPrepareForCartAdvancedEmptyShoppingCart()
586596
'getData',
587597
'getQty',
588598
'getBundleOption',
589-
'getBundleOptionQty'
599+
'getBundleOptionQty',
600+
'getBundleOptionsData',
590601
]
591602
)
592603
->disableOriginalConstructor()
@@ -811,7 +822,8 @@ public function testPrepareForCartAdvancedStringInResult()
811822
'getData',
812823
'getQty',
813824
'getBundleOption',
814-
'getBundleOptionQty'
825+
'getBundleOptionQty',
826+
'getBundleOptionsData',
815827
]
816828
)
817829
->disableOriginalConstructor()
@@ -1030,7 +1042,8 @@ public function testPrepareForCartAdvancedWithoutSelections()
10301042
'getData',
10311043
'getQty',
10321044
'getBundleOption',
1033-
'getBundleOptionQty'
1045+
'getBundleOptionQty',
1046+
'getBundleOptionsData',
10341047
]
10351048
)
10361049
->disableOriginalConstructor()
@@ -1131,7 +1144,16 @@ public function testPrepareForCartAdvancedSelectionsSelectionIdsExists()
11311144
/** @var MockObject|DataObject $buyRequest */
11321145
$buyRequest = $this->getMockBuilder(DataObject::class)
11331146
->setMethods(
1134-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1147+
[
1148+
'__wakeup',
1149+
'getOptions',
1150+
'getSuperProductConfig',
1151+
'unsetData',
1152+
'getData',
1153+
'getQty',
1154+
'getBundleOption',
1155+
'getBundleOptionsData',
1156+
]
11351157
)
11361158
->disableOriginalConstructor()
11371159
->getMock();
@@ -1258,7 +1280,16 @@ public function testPrepareForCartAdvancedSelectRequiredOptions()
12581280
/** @var MockObject|DataObject $buyRequest */
12591281
$buyRequest = $this->getMockBuilder(DataObject::class)
12601282
->setMethods(
1261-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1283+
[
1284+
'__wakeup',
1285+
'getOptions',
1286+
'getSuperProductConfig',
1287+
'unsetData',
1288+
'getData',
1289+
'getQty',
1290+
'getBundleOption',
1291+
'getBundleOptionsData',
1292+
]
12621293
)
12631294
->disableOriginalConstructor()
12641295
->getMock();
@@ -1422,7 +1453,16 @@ public function testPrepareForCartAdvancedAllRequiredOption()
14221453
/** @var MockObject|DataObject $buyRequest */
14231454
$buyRequest = $this->getMockBuilder(DataObject::class)
14241455
->setMethods(
1425-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1456+
[
1457+
'__wakeup',
1458+
'getOptions',
1459+
'getSuperProductConfig',
1460+
'unsetData',
1461+
'getData',
1462+
'getQty',
1463+
'getBundleOption',
1464+
'getBundleOptionsData',
1465+
]
14261466
)
14271467
->disableOriginalConstructor()
14281468
->getMock();
@@ -1523,7 +1563,16 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15231563
/** @var MockObject|DataObject $buyRequest */
15241564
$buyRequest = $this->getMockBuilder(DataObject::class)
15251565
->setMethods(
1526-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1566+
[
1567+
'__wakeup',
1568+
'getOptions',
1569+
'getSuperProductConfig',
1570+
'unsetData',
1571+
'getData',
1572+
'getQty',
1573+
'getBundleOption',
1574+
'getBundleOptionsData',
1575+
]
15271576
)
15281577
->disableOriginalConstructor()
15291578
->getMock();

app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option/selection.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ Bundle.Selection.prototype = {
159159
$grid.find('.checkbox').prop({checked: false});
160160
161161
var checkRowBySku = function (sku) {
162-
sku = $.trim(sku);
162+
sku = sku.trim();
163163
$grid.find('.sku').filter(function () {
164-
return $.trim($(this).text()) == sku;
164+
return $(this).text().trim() == sku;
165165
}).closest('tr').find('.checkbox').prop({checked: true});
166166
};
167167
$.each(bSelection.gridSelection.values().pop().toArray(), function () {

app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ define([
146146

147147
if ($(this).is(':checked')) {
148148
selectedProductList[$(this).val()] = {
149-
name: $.trim(tr.find('.col-name').html()),
150-
sku: $.trim(tr.find('.col-sku').html()),
149+
name: tr.find('.col-name').html().trim(),
150+
sku: tr.find('.col-sku').html().trim(),
151151
'product_id': $(this).val(),
152152
'option_id': $('bundle_selection_id_' + optionIndex).val(),
153153
'selection_price_value': 0,
@@ -186,7 +186,7 @@ define([
186186
});
187187
bSelection.gridRemoval.each(function (pair) {
188188
$optionBox.find('.col-sku').filter(function () {
189-
return $.trim($(this).text()) === pair.key; // find row by SKU
189+
return $(this).text().trim() === pair.key; // find row by SKU
190190
}).closest('tr').find('button.delete').trigger('click');
191191
});
192192
widget.refreshSortableElements();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ define([
7777
.closest(this.options.summaryContainer)
7878
.find(this.options.templates.summaryBlock)
7979
.html();
80-
template = mageTemplate($.trim(template), {
80+
template = mageTemplate(template.trim(), {
8181
data: {
8282
_label_: this.cache.currentElement.options[key].title
8383
}
@@ -107,7 +107,7 @@ define([
107107
.closest(this.options.summaryContainer)
108108
.find(this.options.templates.optionBlock)
109109
.html();
110-
template = mageTemplate($.trim(template), {
110+
template = mageTemplate(template.trim(), {
111111
data: {
112112
_quantity_: this.cache.currentElement.options[this.cache.currentKey].selections[optionIndex].qty,
113113
_label_: this.cache.currentElement.options[this.cache.currentKey].selections[optionIndex].name

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,26 @@ public function getJsonConfig()
177177
{
178178
/* @var $product \Magento\Catalog\Model\Product */
179179
$product = $this->getProduct();
180+
$tierPrices = [];
181+
$priceInfo = $product->getPriceInfo();
182+
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
183+
foreach ($tierPricesList as $tierPrice) {
184+
$tierPriceData = [
185+
'qty' => $tierPrice['price_qty'],
186+
'price' => $tierPrice['website_price'],
187+
];
188+
$tierPrices[] = $tierPriceData;
189+
}
180190

181191
if (!$this->hasOptions()) {
182192
$config = [
183193
'productId' => $product->getId(),
184-
'priceFormat' => $this->_localeFormat->getPriceFormat()
194+
'priceFormat' => $this->_localeFormat->getPriceFormat(),
195+
'tierPrices' => $tierPrices
185196
];
186197
return $this->_jsonEncoder->encode($config);
187198
}
188199

189-
$tierPrices = [];
190-
$priceInfo = $product->getPriceInfo();
191-
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
192-
foreach ($tierPricesList as $tierPrice) {
193-
$tierPrices[] = $tierPrice['price']->getValue() * 1;
194-
}
195200
$config = [
196201
'productId' => (int)$product->getId(),
197202
'priceFormat' => $this->_localeFormat->getPriceFormat(),

0 commit comments

Comments
 (0)