Skip to content

Commit ad44545

Browse files
authored
Merge pull request #4678 from magento-tsg-csl3/2.3-develop-pr30
[TSG-CSL3] For 2.3 (pr30)
2 parents 39cfaa7 + ecaa306 commit ad44545

File tree

24 files changed

+959
-101
lines changed

24 files changed

+959
-101
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Backend\Block\Widget\Grid\Massaction;
87

8+
use Magento\Framework\Data\Collection\AbstractDb;
9+
use Magento\Framework\DB\Select;
10+
911
/**
1012
* Grid widget massaction block
1113
*
1214
* @api
1315
* @deprecated 100.2.0 in favour of UI component implementation
1416
* @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
1517
* @method boolean getHideFormElement()
16-
* @author Magento Core Team <[email protected]>
18+
* @author Magento Core Team <[email protected]>
1719
* @TODO MAGETWO-31510: Remove deprecated class
1820
* @since 100.0.2
1921
*/
@@ -156,7 +158,7 @@ public function getItemsJson()
156158
*/
157159
public function getCount()
158160
{
159-
return sizeof($this->_items);
161+
return count($this->_items);
160162
}
161163

162164
/**
@@ -248,6 +250,8 @@ public function getApplyButtonHtml()
248250
}
249251

250252
/**
253+
* Get mass action javascript code
254+
*
251255
* @return string
252256
*/
253257
public function getJavaScript()
@@ -264,6 +268,8 @@ public function getJavaScript()
264268
}
265269

266270
/**
271+
* Get grid ids in JSON format
272+
*
267273
* @return string
268274
*/
269275
public function getGridIdsJson()
@@ -281,15 +287,24 @@ public function getGridIdsJson()
281287
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
282288
}
283289

284-
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
285-
286-
if (!empty($gridIds)) {
287-
return join(",", $gridIds);
290+
if ($allIdsCollection instanceof AbstractDb) {
291+
$idsSelect = clone $allIdsCollection->getSelect();
292+
$idsSelect->reset(Select::ORDER);
293+
$idsSelect->reset(Select::LIMIT_COUNT);
294+
$idsSelect->reset(Select::LIMIT_OFFSET);
295+
$idsSelect->reset(Select::COLUMNS);
296+
$idsSelect->columns($massActionIdField);
297+
$idList = $allIdsCollection->getConnection()->fetchCol($idsSelect);
298+
} else {
299+
$idList = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
288300
}
289-
return '';
301+
302+
return implode(',', $idList);
290303
}
291304

292305
/**
306+
* Retrieve massaction block js object name
307+
*
293308
* @return string
294309
*/
295310
public function getHtmlId()

app/code/Magento/Bundle/Plugin/UpdatePriceInQuoteItemOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function afterCalcRowTotal(OrigQuoteItem $subject, AbstractItem $result)
4242
{
4343
$bundleAttributes = $result->getProduct()->getCustomOption('bundle_selection_attributes');
4444
if ($bundleAttributes !== null) {
45-
$actualPrice = $result->getPrice();
45+
$actualPrice = (float)$result->getPrice();
4646
$parsedValue = $this->serializer->unserialize($bundleAttributes->getValue());
4747
if (is_array($parsedValue) && array_key_exists('price', $parsedValue)) {
4848
$parsedValue['price'] = $actualPrice;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontSpecialPriceBundleProductInCartTest">
11+
<annotations>
12+
<features value="Bundle"/>
13+
<stories value="Add bundle product to cart on storefront"/>
14+
<title value="Customer should not be able to add a Bundle Product to the cart when added a special price for associated products"/>
15+
<description value="Customer should not be able to add a Bundle Product to the cart when added a special price for associated products"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-19134"/>
18+
<useCaseId value="MC-18963"/>
19+
<group value="bundle"/>
20+
</annotations>
21+
<before>
22+
<!-- Create the Simple product with Special price -->
23+
<createData entity="SimpleProduct2" stepKey="simpleProduct"/>
24+
<createData entity="specialProductPrice2" stepKey="specialPriceToSimpleProduct">
25+
<requiredEntity createDataKey="simpleProduct"/>
26+
</createData>
27+
<!-- Create the bundle product -->
28+
<createData entity="ApiBundleProduct" stepKey="bundleProduct"/>
29+
<createData entity="RadioButtonsOption" stepKey="bundleOption">
30+
<requiredEntity createDataKey="bundleProduct"/>
31+
<field key="required">true</field>
32+
</createData>
33+
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct">
34+
<requiredEntity createDataKey="bundleProduct"/>
35+
<requiredEntity createDataKey="bundleOption"/>
36+
<requiredEntity createDataKey="simpleProduct"/>
37+
</createData>
38+
<!-- Run reindex stock status -->
39+
<magentoCLI command="indexer:reindex" arguments="cataloginventory_stock" stepKey="reindex"/>
40+
</before>
41+
<after>
42+
<deleteData createDataKey="bundleProduct" stepKey="deleteBundleProduct"/>
43+
<deleteData createDataKey="simpleProduct" stepKey="deleteSimpleProduct"/>
44+
</after>
45+
<!-- Go to storefront BundleProduct -->
46+
<amOnPage url="{{StorefrontProductPage.url($$bundleProduct.custom_attributes[url_key]$$)}}" stepKey="goToStorefront"/>
47+
<actionGroup ref="StorefrontAddBundleProductFromProductToCartActionGroup" stepKey="addProductToCartFirstTime">
48+
<argument name="productName" value="$$bundleProduct.name$$"/>
49+
</actionGroup>
50+
<actionGroup ref="StorefrontAddBundleProductFromProductToCartActionGroup" stepKey="addProductToCartSecondTime">
51+
<argument name="productName" value="$$bundleProduct.name$$"/>
52+
</actionGroup>
53+
<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/>
54+
<actionGroup ref="AssertStorefrontMiniCartSubtotalActionGroup" stepKey="assertSubtotal">
55+
<argument name="subtotal" value="$111.10"/>
56+
</actionGroup>
57+
</test>
58+
</tests>

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,12 @@ protected function _getNewOptionsWithTheSameTitlesErrorRows(array $sourceProduct
684684
ksort($outerTitles);
685685
ksort($innerTitles);
686686
if ($outerTitles === $innerTitles) {
687-
$errorRows = array_merge($errorRows, $innerData['rows'], $outerData['rows']);
687+
foreach ($innerData['rows'] as $innerDataRow) {
688+
$errorRows[] = $innerDataRow;
689+
}
690+
foreach ($outerData['rows'] as $outerDataRow) {
691+
$errorRows[] = $outerDataRow;
692+
}
688693
}
689694
}
690695
}
@@ -719,7 +724,9 @@ protected function _findOldOptionsWithTheSameTitles()
719724
}
720725
}
721726
if ($optionsCount > 1) {
722-
$errorRows = array_merge($errorRows, $outerData['rows']);
727+
foreach ($outerData['rows'] as $dataRow) {
728+
$errorRows[] = $dataRow;
729+
}
723730
}
724731
}
725732
}
@@ -747,7 +754,9 @@ protected function _findNewOldOptionsTypeMismatch()
747754
ksort($outerTitles);
748755
ksort($innerTitles);
749756
if ($outerTitles === $innerTitles && $outerData['type'] != $innerData['type']) {
750-
$errorRows = array_merge($errorRows, $outerData['rows']);
757+
foreach ($outerData['rows'] as $dataRow) {
758+
$errorRows[] = $dataRow;
759+
}
751760
}
752761
}
753762
}
@@ -959,8 +968,10 @@ public function validateRow(array $rowData, $rowNumber)
959968

960969
$multiRowData = $this->_getMultiRowFormat($rowData);
961970

962-
foreach ($multiRowData as $optionData) {
963-
$combinedData = array_merge($rowData, $optionData);
971+
foreach ($multiRowData as $combinedData) {
972+
foreach ($rowData as $key => $field) {
973+
$combinedData[$key] = $field;
974+
}
964975

965976
if ($this->_isRowWithCustomOption($combinedData)) {
966977
if ($this->_isMainOptionRow($combinedData)) {
@@ -1109,15 +1120,15 @@ protected function _getMultiRowFormat($rowData)
11091120
foreach ($rowData['custom_options'] as $name => $customOption) {
11101121
$i++;
11111122
foreach ($customOption as $rowOrder => $optionRow) {
1112-
$row = array_merge(
1113-
[
1114-
self::COLUMN_STORE => '',
1115-
self::COLUMN_TITLE => $name,
1116-
self::COLUMN_SORT_ORDER => $i,
1117-
self::COLUMN_ROW_SORT => $rowOrder
1118-
],
1119-
$this->processOptionRow($name, $optionRow)
1120-
);
1123+
$row = [
1124+
self::COLUMN_STORE => '',
1125+
self::COLUMN_TITLE => $name,
1126+
self::COLUMN_SORT_ORDER => $i,
1127+
self::COLUMN_ROW_SORT => $rowOrder
1128+
];
1129+
foreach ($this->processOptionRow($name, $optionRow) as $key => $value) {
1130+
$row[$key] = $value;
1131+
}
11211132
$name = '';
11221133
$multiRow[] = $row;
11231134
}
@@ -1215,6 +1226,8 @@ private function addFileOptions($result, $optionRow)
12151226
*
12161227
* @return boolean
12171228
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1229+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1230+
* @SuppressWarnings(PHPMD.NPathComplexity)
12181231
*/
12191232
protected function _importData()
12201233
{
@@ -1256,9 +1269,11 @@ protected function _importData()
12561269
$optionsToRemove[] = $this->_rowProductId;
12571270
}
12581271
}
1259-
foreach ($multiRowData as $optionData) {
1260-
$combinedData = array_merge($rowData, $optionData);
12611272

1273+
foreach ($multiRowData as $combinedData) {
1274+
foreach ($rowData as $key => $field) {
1275+
$combinedData[$key] = $field;
1276+
}
12621277
if (!$this->isRowAllowedToImport($combinedData, $rowNumber)
12631278
|| !$this->_parseRequiredData($combinedData)
12641279
) {
@@ -1441,7 +1456,9 @@ protected function _collectOptionMainData(
14411456
if (!$this->_isRowHasSpecificType($this->_rowType)
14421457
&& ($priceData = $this->_getPriceData($rowData, $nextOptionId, $this->_rowType))
14431458
) {
1444-
$prices[$nextOptionId] = $priceData;
1459+
if ($this->_isPriceGlobal) {
1460+
$prices[$nextOptionId][Store::DEFAULT_STORE_ID] = $priceData;
1461+
}
14451462
}
14461463

14471464
if (!isset($products[$this->_rowProductId])) {
@@ -1547,6 +1564,7 @@ protected function _collectOptionTitle(array $rowData, $prevOptionId, array &$ti
15471564
* @param array &$prices
15481565
* @param array &$typeValues
15491566
* @return $this
1567+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
15501568
*/
15511569
protected function _compareOptionsWithExisting(array &$options, array &$titles, array &$prices, array &$typeValues)
15521570
{
@@ -1557,7 +1575,9 @@ protected function _compareOptionsWithExisting(array &$options, array &$titles,
15571575
$titles[$optionId] = $titles[$newOptionId];
15581576
unset($titles[$newOptionId]);
15591577
if (isset($prices[$newOptionId])) {
1560-
$prices[$newOptionId]['option_id'] = $optionId;
1578+
foreach ($prices[$newOptionId] as $storeId => $priceStoreData) {
1579+
$prices[$newOptionId][$storeId]['option_id'] = $optionId;
1580+
}
15611581
}
15621582
if (isset($typeValues[$newOptionId])) {
15631583
$typeValues[$optionId] = $typeValues[$newOptionId];
@@ -1590,8 +1610,10 @@ private function restoreOriginalOptionTypeIds(array &$typeValues, array &$typePr
15901610
$optionType['option_type_id'] = $existingTypeId;
15911611
$typeTitles[$existingTypeId] = $typeTitles[$optionTypeId];
15921612
unset($typeTitles[$optionTypeId]);
1593-
$typePrices[$existingTypeId] = $typePrices[$optionTypeId];
1594-
unset($typePrices[$optionTypeId]);
1613+
if (isset($typePrices[$optionTypeId])) {
1614+
$typePrices[$existingTypeId] = $typePrices[$optionTypeId];
1615+
unset($typePrices[$optionTypeId]);
1616+
}
15951617
// If option type titles match at least in one store, consider current option type as existing
15961618
break;
15971619
}
@@ -1651,7 +1673,7 @@ protected function _parseRequiredData(array $rowData)
16511673
if (!isset($this->_storeCodeToId[$rowData[self::COLUMN_STORE]])) {
16521674
return false;
16531675
}
1654-
$this->_rowStoreId = $this->_storeCodeToId[$rowData[self::COLUMN_STORE]];
1676+
$this->_rowStoreId = (int)$this->_storeCodeToId[$rowData[self::COLUMN_STORE]];
16551677
} else {
16561678
$this->_rowStoreId = Store::DEFAULT_STORE_ID;
16571679
}
@@ -1767,7 +1789,7 @@ protected function _getPriceData(array $rowData, $optionId, $type)
17671789
) {
17681790
$priceData = [
17691791
'option_id' => $optionId,
1770-
'store_id' => Store::DEFAULT_STORE_ID,
1792+
'store_id' => $this->_rowStoreId,
17711793
'price_type' => 'fixed',
17721794
];
17731795

@@ -1901,11 +1923,19 @@ protected function _saveTitles(array $titles)
19011923
protected function _savePrices(array $prices)
19021924
{
19031925
if ($prices) {
1904-
$this->_connection->insertOnDuplicate(
1905-
$this->_tables['catalog_product_option_price'],
1906-
$prices,
1907-
['price', 'price_type']
1908-
);
1926+
$optionPriceRows = [];
1927+
foreach ($prices as $storesData) {
1928+
foreach ($storesData as $row) {
1929+
$optionPriceRows[] = $row;
1930+
}
1931+
}
1932+
if ($optionPriceRows) {
1933+
$this->_connection->insertOnDuplicate(
1934+
$this->_tables['catalog_product_option_price'],
1935+
$optionPriceRows,
1936+
['price', 'price_type']
1937+
);
1938+
}
19091939
}
19101940

19111941
return $this;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class OptionTest extends \Magento\ImportExport\Test\Unit\Model\Import\AbstractIm
7979
* @var array
8080
*/
8181
protected $_expectedPrices = [
82-
2 => ['option_id' => 2, 'store_id' => 0, 'price_type' => 'fixed', 'price' => 0],
83-
3 => ['option_id' => 3, 'store_id' => 0, 'price_type' => 'fixed', 'price' => 2]
82+
0 => ['option_id' => 2, 'store_id' => 0, 'price_type' => 'fixed', 'price' => 0],
83+
1 => ['option_id' => 3, 'store_id' => 0, 'price_type' => 'fixed', 'price' => 2]
8484
];
8585

8686
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontMiniCartSubtotalActionGroup">
11+
<arguments>
12+
<argument name="subtotal" type="string"/>
13+
</arguments>
14+
<waitForElementVisible selector="{{StorefrontMinicartSection.productSubTotal}}" stepKey="waitForSubtotal"/>
15+
<see selector="{{StorefrontMinicartSection.productSubTotal}}" userInput="{{subtotal}}" stepKey="seeSubtotal"/>
16+
</actionGroup>
17+
</actionGroups>

0 commit comments

Comments
 (0)