Skip to content

Commit 95c3b79

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 4fbc991 + 5351c27 commit 95c3b79

File tree

43 files changed

+1680
-9004
lines changed

Some content is hidden

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

43 files changed

+1680
-9004
lines changed
Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
AdvancedSearch module introduces advanced search functionality and provides interfaces that allow to implement this functionality by 3rd party search engines
1+
# Magento_AdvancedSearch module
2+
The Magento_AdvancedSearch module introduces advanced search functionality and provides interfaces that allow third-party search engines to implement this functionality.
3+
4+
## Installation details
5+
6+
Before disabling or uninstalling this module, note that the following modules depends on this module:
7+
- Magento_Elasticsearch
8+
- Magento_Elasticsearch6
9+
10+
For information about module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-enable.html).
11+
12+
## Extensibility
13+
14+
Extension developers can interact with the Magento_AdvancedSearch module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
15+
16+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_AdvancedSearch module.
17+
18+
### Events
19+
20+
This module observes the following event:
21+
22+
- `catalogsearch_query_save_after` in the `Magento\AdvancedSearch\Model\Recommendations\SaveSearchQueryRelationsObserver` file.
23+
24+
For information about an event in Magento 2, see [Events and observers](http://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html#events).
25+
26+
### Layouts
27+
28+
The module interacts with the following layout handles in the `view/adminhtml/layout` directory:
29+
30+
- `catalog_search_block`
31+
- `catalog_search_edit`
32+
- `catalog_search_relatedgrid`
33+
34+
The module interacts with the following layout handles in the `view/frontend/layout` directory:
35+
36+
- `catalogsearch_result_index`
37+
38+
For more information about layouts in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html).

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 <core@magentocommerce.com>
18+
* @author Magento Core Team <core@magentocommerce.com>
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/Backend/etc/adminhtml/system.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
<field id="allow_symlink" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
146146
<label>Allow Symlinks</label>
147147
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
148-
<comment>Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk.</comment>
148+
<comment>
149+
<![CDATA[<strong style="color:red">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk.]]>
150+
</comment>
149151
</field>
150152
<field id="minify_html" translate="label comment" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
151153
<label>Minify Html</label>
@@ -435,7 +437,7 @@
435437
<label>Admin Session Lifetime (seconds)</label>
436438
<comment>Please enter at least 60 and at most 31536000 (one year).</comment>
437439
<backend_model>Magento\Backend\Model\Config\SessionLifetime\BackendModel</backend_model>
438-
<validate>validate-digits</validate>
440+
<validate>validate-digits validate-digits-range digits-range-60-31536000</validate>
439441
</field>
440442
</group>
441443
<group id="dashboard" translate="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Debug,Debug
333333
"Add Block Names to Hints","Add Block Names to Hints"
334334
"Template Settings","Template Settings"
335335
"Allow Symlinks","Allow Symlinks"
336-
"Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk.","Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk."
336+
"<strong style=""color:red"">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk.","<strong style=""color:red"">Warning!</strong> Enabling this feature is not recommended on production environments because it represents a potential security risk."
337337
"Minify Html","Minify Html"
338338
"Minification is not applied in developer mode.","Minification is not applied in developer mode."
339339
"Translate Inline","Translate Inline"

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;

0 commit comments

Comments
 (0)