Skip to content

Commit f8f1e5e

Browse files
authored
Merge pull request #5858 from magento-tsg-csl3/2.4-develop-pr33
[TSG-CSL3] For 2.4|2.4|1.2 (pr33)
2 parents cb1719f + 13fc286 commit f8f1e5e

File tree

16 files changed

+552
-29
lines changed

16 files changed

+552
-29
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,20 @@ protected function _reindexRows($changedIds = [])
368368
$productsTypes = $this->getProductsTypes($changedIds);
369369
$parentProductsTypes = $this->getParentProductsTypes($changedIds);
370370

371-
$changedIds = array_merge($changedIds, ...array_values($parentProductsTypes));
371+
$changedIds = array_unique(array_merge($changedIds, ...array_values($parentProductsTypes)));
372372
$productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes);
373373

374374
if ($changedIds) {
375375
$this->deleteIndexData($changedIds);
376376
}
377-
foreach ($productsTypes as $productType => $entityIds) {
378-
$indexer = $this->_getIndexer($productType);
377+
378+
$typeIndexers = $this->getTypeIndexers();
379+
foreach ($typeIndexers as $productType => $indexer) {
380+
$entityIds = $productsTypes[$productType] ?? [];
381+
if (empty($entityIds)) {
382+
continue;
383+
}
384+
379385
if ($indexer instanceof DimensionalIndexerInterface) {
380386
foreach ($this->dimensionCollectionFactory->create() as $dimensions) {
381387
$this->tableMaintainer->createMainTmpTable($dimensions);

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductContentSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<element name="shortDescriptionTextArea" type="textarea" selector="#product_form_short_description"/>
1616
<element name="sectionHeaderIfNotShowing" type="button" selector="//div[@data-index='content']//div[contains(@class, '_hide')]"/>
1717
<element name="pageHeader" type="textarea" selector="//*[@class='page-header row']"/>
18+
<element name="attributeInput" type="input" selector="input[name='product[{{attributeCode}}]']" parameterized="true"/>
1819
</section>
1920
</sections>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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="AdminChangeProductAttributeGroupTest">
11+
<annotations>
12+
<title value="Preserving attribute value after attribute group is changed"/>
13+
<description value="Attribute value should be preserved after changing attribute group"/>
14+
<severity value="CRITICAL"/>
15+
<testCaseId value="MC-35612"/>
16+
<useCaseId value="MC-31892"/>
17+
<group value="catalog"/>
18+
</annotations>
19+
<before>
20+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
21+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
22+
<requiredEntity createDataKey="createCategory"/>
23+
</createData>
24+
25+
<createData entity="productAttributeText" stepKey="createProductAttribute"/>
26+
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
27+
<createData entity="CatalogAttributeSet" stepKey="createSecondAttributeSet"/>
28+
29+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
30+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createAttributeSet.attribute_set_id$/"
31+
stepKey="onAttributeSetEdit"/>
32+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
33+
<argument name="group" value="Product Details"/>
34+
<argument name="attribute" value="$createProductAttribute.attribute_code$"/>
35+
</actionGroup>
36+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>
37+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createSecondAttributeSet.attribute_set_id$/"
38+
stepKey="onSecondAttributeSetEdit"/>
39+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToContentGroup">
40+
<argument name="group" value="Content"/>
41+
<argument name="attribute" value="$createProductAttribute.attribute_code$"/>
42+
</actionGroup>
43+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveSecondAttributeSet"/>
44+
</before>
45+
<after>
46+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
47+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
48+
<deleteData createDataKey="createProductAttribute" stepKey="deleteProductAttribute"/>
49+
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/>
50+
<deleteData createDataKey="createSecondAttributeSet" stepKey="deleteSecondAttributeSet"/>
51+
<actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/>
52+
53+
<!-- Reindex invalidated indices after product attribute has been created/deleted -->
54+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
55+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
56+
</after>
57+
58+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
59+
<argument name="product" value="$createSimpleProduct$"/>
60+
</actionGroup>
61+
62+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1">
63+
<argument name="product" value="$createSimpleProduct$"/>
64+
</actionGroup>
65+
66+
<actionGroup ref="AdminProductPageSelectAttributeSetActionGroup" stepKey="selectAttributeSet">
67+
<argument name="attributeSetName" value="$createAttributeSet.attribute_set_name$"/>
68+
</actionGroup>
69+
<waitForText userInput="$createProductAttribute.default_frontend_label$" stepKey="seeAttributeInForm"/>
70+
<fillField selector="{{AdminProductFormSection.attributeRequiredInput($createProductAttribute.attribute_code$)}}"
71+
userInput="test"
72+
stepKey="fillProductAttributeValue"/>
73+
<actionGroup ref="AdminProductPageSelectAttributeSetActionGroup" stepKey="selectSecondAttributeSet">
74+
<argument name="attributeSetName" value="$createSecondAttributeSet.attribute_set_name$"/>
75+
</actionGroup>
76+
<actionGroup ref="ExpandAdminProductSectionActionGroup" stepKey="expandContentSection"/>
77+
<waitForText userInput="$createProductAttribute.default_frontend_label$" stepKey="seeAttributeInSection"/>
78+
<grabValueFrom selector="{{AdminProductContentSection.attributeInput($createProductAttribute.attribute_code$)}}"
79+
stepKey="attributeValue"/>
80+
<assertEquals stepKey="assertAttributeValue">
81+
<expectedResult type="string">test</expectedResult>
82+
<actualResult type="variable">attributeValue</actualResult>
83+
</assertEquals>
84+
</test>
85+
</tests>

app/code/Magento/Sales/Model/ResourceModel/Order/Address/Collection.php

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
namespace Magento\Sales\Model\ResourceModel\Order\Address;
77

88
use Magento\Sales\Api\Data\OrderAddressSearchResultInterface;
9-
use \Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection;
9+
use Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection;
10+
use Magento\Framework\Locale\ResolverInterface;
11+
use Magento\Framework\Data\Collection\EntityFactoryInterface;
12+
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
13+
use Magento\Framework\Event\ManagerInterface;
14+
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
15+
use Magento\Framework\DB\Adapter\AdapterInterface;
16+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
17+
use Magento\Framework\App\ObjectManager;
18+
use Psr\Log\LoggerInterface;
1019

1120
/**
12-
* Flat sales order payment collection
13-
*
14-
* @author Magento Core Team <[email protected]>
21+
* Order addresses collection
1522
*/
1623
class Collection extends AbstractCollection implements OrderAddressSearchResultInterface
1724
{
@@ -29,6 +36,44 @@ class Collection extends AbstractCollection implements OrderAddressSearchResultI
2936
*/
3037
protected $_eventObject = 'order_address_collection';
3138

39+
/**
40+
* @var ResolverInterface
41+
*/
42+
private $localeResolver;
43+
44+
/**
45+
* @param EntityFactoryInterface $entityFactory
46+
* @param LoggerInterface $logger
47+
* @param FetchStrategyInterface $fetchStrategy
48+
* @param ManagerInterface $eventManager
49+
* @param Snapshot $entitySnapshot
50+
* @param AdapterInterface|null $connection
51+
* @param AbstractDb|null $resource
52+
* @param ResolverInterface|null $localeResolver
53+
*/
54+
public function __construct(
55+
EntityFactoryInterface $entityFactory,
56+
LoggerInterface $logger,
57+
FetchStrategyInterface $fetchStrategy,
58+
ManagerInterface $eventManager,
59+
Snapshot $entitySnapshot,
60+
AdapterInterface $connection = null,
61+
AbstractDb $resource = null,
62+
ResolverInterface $localeResolver = null
63+
) {
64+
$this->localeResolver = $localeResolver ?: ObjectManager::getInstance()
65+
->get(ResolverInterface::class);
66+
parent::__construct(
67+
$entityFactory,
68+
$logger,
69+
$fetchStrategy,
70+
$eventManager,
71+
$entitySnapshot,
72+
$connection,
73+
$resource
74+
);
75+
}
76+
3277
/**
3378
* Model initialization
3479
*
@@ -42,6 +87,16 @@ protected function _construct()
4287
);
4388
}
4489

90+
/**
91+
* @inheritdoc
92+
*/
93+
protected function _initSelect()
94+
{
95+
parent::_initSelect();
96+
$this->joinRegions();
97+
return $this;
98+
}
99+
45100
/**
46101
* Redeclare after load method for dispatch event
47102
*
@@ -55,4 +110,31 @@ protected function _afterLoad()
55110

56111
return $this;
57112
}
113+
114+
/**
115+
* Join region name table with current locale
116+
*
117+
* @return $this
118+
*/
119+
private function joinRegions()
120+
{
121+
$locale = $this->localeResolver->getLocale();
122+
$connection = $this->getConnection();
123+
124+
$defaultNameExpr = $connection->getIfNullSql(
125+
$connection->quoteIdentifier('rct.default_name'),
126+
$connection->quoteIdentifier('main_table.region')
127+
);
128+
$expression = $connection->getIfNullSql($connection->quoteIdentifier('rnt.name'), $defaultNameExpr);
129+
130+
$regionId = $connection->quoteIdentifier('main_table.region_id');
131+
$condition = $connection->quoteInto("rnt.locale=?", $locale);
132+
$rctTable = $this->getTable('directory_country_region');
133+
$rntTable = $this->getTable('directory_country_region_name');
134+
135+
$this->getSelect()
136+
->joinLeft(['rct' => $rctTable], "rct.region_id={$regionId}", [])
137+
->joinLeft(['rnt' => $rntTable], "rnt.region_id={$regionId} AND {$condition}", ['region' => $expression]);
138+
return $this;
139+
}
58140
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Search\ViewModel;
9+
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Store\Model\ScopeInterface;
13+
14+
/**
15+
* View model for search
16+
*/
17+
class ConfigProvider implements ArgumentInterface
18+
{
19+
/**
20+
* Suggestions settings config paths
21+
*/
22+
private const SEARCH_SUGGESTION_ENABLED = 'catalog/search/search_suggestion_enabled';
23+
24+
/**
25+
* @var ScopeConfigInterface
26+
*/
27+
private $scopeConfig;
28+
29+
/**
30+
* @param ScopeConfigInterface $scopeConfig
31+
*/
32+
public function __construct(
33+
ScopeConfigInterface $scopeConfig
34+
) {
35+
$this->scopeConfig = $scopeConfig;
36+
}
37+
38+
/**
39+
* Is Search Suggestions Allowed
40+
*
41+
* @return bool
42+
*/
43+
public function isSuggestionsAllowed(): bool
44+
{
45+
return $this->scopeConfig->isSetFlag(
46+
self::SEARCH_SUGGESTION_ENABLED,
47+
ScopeInterface::SCOPE_STORE
48+
);
49+
}
50+
}

app/code/Magento/Search/view/frontend/layout/default.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
1010
<referenceContainer name="header-wrapper">
11-
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml" />
11+
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml">
12+
<arguments>
13+
<argument name="configProvider" xsi:type="object">Magento\Search\ViewModel\ConfigProvider</argument>
14+
</arguments>
15+
</block>
1216
</referenceContainer>
1317
<referenceBlock name="footer_links">
1418
<block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="catalog/seo/search_terms" name="search-term-popular-link">

app/code/Magento/Search/view/frontend/templates/form.mini.phtml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<?php
1010
/** @var $block \Magento\Framework\View\Element\Template */
1111
/** @var $helper \Magento\Search\Helper\Data */
12+
/** @var $configProvider \Magento\Search\ViewModel\ConfigProvider */
1213
$helper = $this->helper(\Magento\Search\Helper\Data::class);
14+
$configProvider = $block->getData('configProvider');
1315
?>
1416
<div class="block block-search">
1517
<div class="block block-title"><strong><?= $block->escapeHtml(__('Search')) ?></strong></div>
@@ -22,12 +24,14 @@ $helper = $this->helper(\Magento\Search\Helper\Data::class);
2224
</label>
2325
<div class="control">
2426
<input id="search"
25-
data-mage-init='{"quickSearch":{
26-
"formSelector":"#search_mini_form",
27-
"url":"<?= $block->escapeUrl($helper->getSuggestUrl())?>",
28-
"destinationSelector":"#search_autocomplete",
29-
"minSearchLength":"<?= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
30-
}'
27+
<?php if ($configProvider->isSuggestionsAllowed()):?>
28+
data-mage-init='{"quickSearch":{
29+
"formSelector":"#search_mini_form",
30+
"url":"<?= $block->escapeUrl($helper->getSuggestUrl())?>",
31+
"destinationSelector":"#search_autocomplete",
32+
"minSearchLength":"<?= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
33+
}'
34+
<?php endif;?>
3135
type="text"
3236
name="<?= $block->escapeHtmlAttr($helper->getQueryParamName()) ?>"
3337
value="<?= /* @noEscape */ $helper->getEscapedQueryText() ?>"

app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ define([
499499
component = registry.get(val.path);
500500

501501
if (component) {
502-
component.cleanData().destroy();
502+
component.destroy();
503503
}
504504
});
505505

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Service\V1;
78

89
use Magento\Sales\Api\Data\OrderAddressInterface as OrderAddress;
910
use Magento\TestFramework\TestCase\WebapiAbstract;
1011

1112
/**
12-
* Class OrderAddressUpdateTest
13+
* Test for address update
1314
*/
1415
class OrderAddressUpdateTest extends WebapiAbstract
1516
{
@@ -28,7 +29,7 @@ public function testOrderAddressUpdate()
2829
$order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
2930

3031
$address = [
31-
OrderAddress::REGION => 'CA',
32+
OrderAddress::REGION => 'California',
3233
OrderAddress::POSTCODE => '11111',
3334
OrderAddress::LASTNAME => 'lastname',
3435
OrderAddress::STREET => ['street'],
@@ -75,7 +76,7 @@ public function testOrderAddressUpdate()
7576
$billingAddress = $actualOrder->getBillingAddress();
7677

7778
$validate = [
78-
OrderAddress::REGION => 'CA',
79+
OrderAddress::REGION => 'California',
7980
OrderAddress::POSTCODE => '11111',
8081
OrderAddress::LASTNAME => 'lastname',
8182
OrderAddress::STREET => 'street',

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testOrderGet(): void
7676
'city' => 'Los Angeles',
7777
'email' => '[email protected]',
7878
'postcode' => '11111',
79-
'region' => 'CA'
79+
'region' => 'California'
8080
];
8181

8282
$result = $this->makeServiceCall(self::ORDER_INCREMENT_ID);

0 commit comments

Comments
 (0)