Skip to content

Commit

Permalink
Merge pull request #5858 from magento-tsg-csl3/2.4-develop-pr33
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4|2.4|1.2 (pr33)
  • Loading branch information
viktym committed Jul 9, 2020
2 parents cb1719f + 13fc286 commit f8f1e5e
Show file tree
Hide file tree
Showing 16 changed files with 552 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,20 @@ protected function _reindexRows($changedIds = [])
$productsTypes = $this->getProductsTypes($changedIds);
$parentProductsTypes = $this->getParentProductsTypes($changedIds);

$changedIds = array_merge($changedIds, ...array_values($parentProductsTypes));
$changedIds = array_unique(array_merge($changedIds, ...array_values($parentProductsTypes)));
$productsTypes = array_merge_recursive($productsTypes, $parentProductsTypes);

if ($changedIds) {
$this->deleteIndexData($changedIds);
}
foreach ($productsTypes as $productType => $entityIds) {
$indexer = $this->_getIndexer($productType);

$typeIndexers = $this->getTypeIndexers();
foreach ($typeIndexers as $productType => $indexer) {
$entityIds = $productsTypes[$productType] ?? [];
if (empty($entityIds)) {
continue;
}

if ($indexer instanceof DimensionalIndexerInterface) {
foreach ($this->dimensionCollectionFactory->create() as $dimensions) {
$this->tableMaintainer->createMainTmpTable($dimensions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<element name="shortDescriptionTextArea" type="textarea" selector="#product_form_short_description"/>
<element name="sectionHeaderIfNotShowing" type="button" selector="//div[@data-index='content']//div[contains(@class, '_hide')]"/>
<element name="pageHeader" type="textarea" selector="//*[@class='page-header row']"/>
<element name="attributeInput" type="input" selector="input[name='product[{{attributeCode}}]']" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminChangeProductAttributeGroupTest">
<annotations>
<title value="Preserving attribute value after attribute group is changed"/>
<description value="Attribute value should be preserved after changing attribute group"/>
<severity value="CRITICAL"/>
<testCaseId value="MC-35612"/>
<useCaseId value="MC-31892"/>
<group value="catalog"/>
</annotations>
<before>
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>

<createData entity="productAttributeText" stepKey="createProductAttribute"/>
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
<createData entity="CatalogAttributeSet" stepKey="createSecondAttributeSet"/>

<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createAttributeSet.attribute_set_id$/"
stepKey="onAttributeSetEdit"/>
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
<argument name="group" value="Product Details"/>
<argument name="attribute" value="$createProductAttribute.attribute_code$"/>
</actionGroup>
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveAttributeSet"/>
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$createSecondAttributeSet.attribute_set_id$/"
stepKey="onSecondAttributeSetEdit"/>
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToContentGroup">
<argument name="group" value="Content"/>
<argument name="attribute" value="$createProductAttribute.attribute_code$"/>
</actionGroup>
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="saveSecondAttributeSet"/>
</before>
<after>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createProductAttribute" stepKey="deleteProductAttribute"/>
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/>
<deleteData createDataKey="createSecondAttributeSet" stepKey="deleteSecondAttributeSet"/>
<actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/>

<!-- Reindex invalidated indices after product attribute has been created/deleted -->
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="$createSimpleProduct$"/>
</actionGroup>

<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1">
<argument name="product" value="$createSimpleProduct$"/>
</actionGroup>

<actionGroup ref="AdminProductPageSelectAttributeSetActionGroup" stepKey="selectAttributeSet">
<argument name="attributeSetName" value="$createAttributeSet.attribute_set_name$"/>
</actionGroup>
<waitForText userInput="$createProductAttribute.default_frontend_label$" stepKey="seeAttributeInForm"/>
<fillField selector="{{AdminProductFormSection.attributeRequiredInput($createProductAttribute.attribute_code$)}}"
userInput="test"
stepKey="fillProductAttributeValue"/>
<actionGroup ref="AdminProductPageSelectAttributeSetActionGroup" stepKey="selectSecondAttributeSet">
<argument name="attributeSetName" value="$createSecondAttributeSet.attribute_set_name$"/>
</actionGroup>
<actionGroup ref="ExpandAdminProductSectionActionGroup" stepKey="expandContentSection"/>
<waitForText userInput="$createProductAttribute.default_frontend_label$" stepKey="seeAttributeInSection"/>
<grabValueFrom selector="{{AdminProductContentSection.attributeInput($createProductAttribute.attribute_code$)}}"
stepKey="attributeValue"/>
<assertEquals stepKey="assertAttributeValue">
<expectedResult type="string">test</expectedResult>
<actualResult type="variable">attributeValue</actualResult>
</assertEquals>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
namespace Magento\Sales\Model\ResourceModel\Order\Address;

use Magento\Sales\Api\Data\OrderAddressSearchResultInterface;
use \Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection;
use Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\App\ObjectManager;
use Psr\Log\LoggerInterface;

/**
* Flat sales order payment collection
*
* @author Magento Core Team <core@magentocommerce.com>
* Order addresses collection
*/
class Collection extends AbstractCollection implements OrderAddressSearchResultInterface
{
Expand All @@ -29,6 +36,44 @@ class Collection extends AbstractCollection implements OrderAddressSearchResultI
*/
protected $_eventObject = 'order_address_collection';

/**
* @var ResolverInterface
*/
private $localeResolver;

/**
* @param EntityFactoryInterface $entityFactory
* @param LoggerInterface $logger
* @param FetchStrategyInterface $fetchStrategy
* @param ManagerInterface $eventManager
* @param Snapshot $entitySnapshot
* @param AdapterInterface|null $connection
* @param AbstractDb|null $resource
* @param ResolverInterface|null $localeResolver
*/
public function __construct(
EntityFactoryInterface $entityFactory,
LoggerInterface $logger,
FetchStrategyInterface $fetchStrategy,
ManagerInterface $eventManager,
Snapshot $entitySnapshot,
AdapterInterface $connection = null,
AbstractDb $resource = null,
ResolverInterface $localeResolver = null
) {
$this->localeResolver = $localeResolver ?: ObjectManager::getInstance()
->get(ResolverInterface::class);
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$entitySnapshot,
$connection,
$resource
);
}

/**
* Model initialization
*
Expand All @@ -42,6 +87,16 @@ protected function _construct()
);
}

/**
* @inheritdoc
*/
protected function _initSelect()
{
parent::_initSelect();
$this->joinRegions();
return $this;
}

/**
* Redeclare after load method for dispatch event
*
Expand All @@ -55,4 +110,31 @@ protected function _afterLoad()

return $this;
}

/**
* Join region name table with current locale
*
* @return $this
*/
private function joinRegions()
{
$locale = $this->localeResolver->getLocale();
$connection = $this->getConnection();

$defaultNameExpr = $connection->getIfNullSql(
$connection->quoteIdentifier('rct.default_name'),
$connection->quoteIdentifier('main_table.region')
);
$expression = $connection->getIfNullSql($connection->quoteIdentifier('rnt.name'), $defaultNameExpr);

$regionId = $connection->quoteIdentifier('main_table.region_id');
$condition = $connection->quoteInto("rnt.locale=?", $locale);
$rctTable = $this->getTable('directory_country_region');
$rntTable = $this->getTable('directory_country_region_name');

$this->getSelect()
->joinLeft(['rct' => $rctTable], "rct.region_id={$regionId}", [])
->joinLeft(['rnt' => $rntTable], "rnt.region_id={$regionId} AND {$condition}", ['region' => $expression]);
return $this;
}
}
50 changes: 50 additions & 0 deletions app/code/Magento/Search/ViewModel/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Search\ViewModel;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Store\Model\ScopeInterface;

/**
* View model for search
*/
class ConfigProvider implements ArgumentInterface
{
/**
* Suggestions settings config paths
*/
private const SEARCH_SUGGESTION_ENABLED = 'catalog/search/search_suggestion_enabled';

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
* Is Search Suggestions Allowed
*
* @return bool
*/
public function isSuggestionsAllowed(): bool
{
return $this->scopeConfig->isSetFlag(
self::SEARCH_SUGGESTION_ENABLED,
ScopeInterface::SCOPE_STORE
);
}
}
6 changes: 5 additions & 1 deletion app/code/Magento/Search/view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header-wrapper">
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml" />
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml">
<arguments>
<argument name="configProvider" xsi:type="object">Magento\Search\ViewModel\ConfigProvider</argument>
</arguments>
</block>
</referenceContainer>
<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="catalog/seo/search_terms" name="search-term-popular-link">
Expand Down
16 changes: 10 additions & 6 deletions app/code/Magento/Search/view/frontend/templates/form.mini.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<?php
/** @var $block \Magento\Framework\View\Element\Template */
/** @var $helper \Magento\Search\Helper\Data */
/** @var $configProvider \Magento\Search\ViewModel\ConfigProvider */
$helper = $this->helper(\Magento\Search\Helper\Data::class);
$configProvider = $block->getData('configProvider');
?>
<div class="block block-search">
<div class="block block-title"><strong><?= $block->escapeHtml(__('Search')) ?></strong></div>
Expand All @@ -22,12 +24,14 @@ $helper = $this->helper(\Magento\Search\Helper\Data::class);
</label>
<div class="control">
<input id="search"
data-mage-init='{"quickSearch":{
"formSelector":"#search_mini_form",
"url":"<?= $block->escapeUrl($helper->getSuggestUrl())?>",
"destinationSelector":"#search_autocomplete",
"minSearchLength":"<?= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
}'
<?php if ($configProvider->isSuggestionsAllowed()):?>
data-mage-init='{"quickSearch":{
"formSelector":"#search_mini_form",
"url":"<?= $block->escapeUrl($helper->getSuggestUrl())?>",
"destinationSelector":"#search_autocomplete",
"minSearchLength":"<?= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
}'
<?php endif;?>
type="text"
name="<?= $block->escapeHtmlAttr($helper->getQueryParamName()) ?>"
value="<?= /* @noEscape */ $helper->getEscapedQueryText() ?>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ define([
component = registry.get(val.path);

if (component) {
component.cleanData().destroy();
component.destroy();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Service\V1;

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

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

$address = [
OrderAddress::REGION => 'CA',
OrderAddress::REGION => 'California',
OrderAddress::POSTCODE => '11111',
OrderAddress::LASTNAME => 'lastname',
OrderAddress::STREET => ['street'],
Expand Down Expand Up @@ -75,7 +76,7 @@ public function testOrderAddressUpdate()
$billingAddress = $actualOrder->getBillingAddress();

$validate = [
OrderAddress::REGION => 'CA',
OrderAddress::REGION => 'California',
OrderAddress::POSTCODE => '11111',
OrderAddress::LASTNAME => 'lastname',
OrderAddress::STREET => 'street',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testOrderGet(): void
'city' => 'Los Angeles',
'email' => 'customer@null.com',
'postcode' => '11111',
'region' => 'CA'
'region' => 'California'
];

$result = $this->makeServiceCall(self::ORDER_INCREMENT_ID);
Expand Down
Loading

0 comments on commit f8f1e5e

Please sign in to comment.