Skip to content

Commit e6112b2

Browse files
committed
Merge branch '2.4-develop' into MC-37718
2 parents 67b9b6a + edfbc39 commit e6112b2

File tree

34 files changed

+688
-256
lines changed

34 files changed

+688
-256
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ public function getOptions(array $optionIds, ?int $storeId, array $attributeCode
6464
'attribute_label' => 'a.frontend_label',
6565
]
6666
)
67+
->joinLeft(
68+
['attribute_label' => $this->resourceConnection->getTableName('eav_attribute_label')],
69+
"a.attribute_id = attribute_label.attribute_id AND attribute_label.store_id = {$storeId}",
70+
[
71+
'attribute_store_label' => 'attribute_label.value',
72+
]
73+
)
6774
->joinLeft(
6875
['options' => $this->resourceConnection->getTableName('eav_attribute_option')],
6976
'a.attribute_id = options.attribute_id',
@@ -119,7 +126,8 @@ private function formatResult(\Magento\Framework\DB\Select $select): array
119126
$result[$option['attribute_code']] = [
120127
'attribute_id' => $option['attribute_id'],
121128
'attribute_code' => $option['attribute_code'],
122-
'attribute_label' => $option['attribute_label'],
129+
'attribute_label' => $option['attribute_store_label']
130+
? $option['attribute_store_label'] : $option['attribute_label'],
123131
'options' => [],
124132
];
125133
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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\CatalogSearch\Model\Search;
9+
10+
use Magento\Backend\Helper\Data;
11+
use Magento\Catalog\Api\CategoryListInterface;
12+
use Magento\Framework\Api\FilterBuilder;
13+
use Magento\Framework\Api\SearchCriteriaBuilder;
14+
use Magento\Framework\Api\SearchCriteriaBuilderFactory;
15+
use Magento\Framework\DataObject;
16+
use Magento\Framework\Stdlib\StringUtils;
17+
18+
/**
19+
* Search model for backend search
20+
*/
21+
class Category extends DataObject
22+
{
23+
/**
24+
* @var Data
25+
*/
26+
private $adminhtmlData = null;
27+
28+
/**
29+
* @var CategoryListInterface
30+
*/
31+
private $categoryRepository;
32+
33+
/**
34+
* @var FilterBuilder
35+
*/
36+
private $filterBuilder;
37+
38+
/**
39+
* @var SearchCriteriaBuilderFactory
40+
*/
41+
private $searchCriteriaBuilderFactory;
42+
43+
/**
44+
* @var StringUtils
45+
*/
46+
private $string;
47+
48+
/**
49+
* @var SearchCriteriaBuilder|void
50+
*/
51+
private $searchCriteriaBuilder;
52+
53+
/**
54+
* @param Data $adminhtmlData
55+
* @param CategoryListInterface $categoryRepository
56+
* @param SearchCriteriaBuilder $searchCriteriaBuilder
57+
* @param SearchCriteriaBuilderFactory $searchCriteriaBuilderFactory
58+
* @param FilterBuilder $filterBuilder
59+
* @param StringUtils $string
60+
*/
61+
public function __construct(
62+
Data $adminhtmlData,
63+
CategoryListInterface $categoryRepository,
64+
SearchCriteriaBuilder $searchCriteriaBuilder,
65+
SearchCriteriaBuilderFactory $searchCriteriaBuilderFactory,
66+
FilterBuilder $filterBuilder,
67+
StringUtils $string
68+
) {
69+
$this->adminhtmlData = $adminhtmlData;
70+
$this->categoryRepository = $categoryRepository;
71+
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
72+
$this->searchCriteriaBuilderFactory = $searchCriteriaBuilderFactory;
73+
$this->filterBuilder = $filterBuilder;
74+
$this->string = $string;
75+
}
76+
77+
/**
78+
* Load search results
79+
*
80+
* @return $this
81+
*/
82+
public function load()
83+
{
84+
$result = [];
85+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
86+
$this->setResults($result);
87+
return $this;
88+
}
89+
$this->searchCriteriaBuilder = $this->searchCriteriaBuilderFactory->create();
90+
$this->searchCriteriaBuilder->setCurrentPage($this->getStart());
91+
$this->searchCriteriaBuilder->setPageSize($this->getLimit());
92+
$searchFields = ['name'];
93+
94+
$filters = [];
95+
foreach ($searchFields as $field) {
96+
$filters[] = $this->filterBuilder
97+
->setField($field)
98+
->setConditionType('like')
99+
->setValue(sprintf("%%%s%%", $this->getQuery()))
100+
->create();
101+
}
102+
$this->searchCriteriaBuilder->addFilters($filters);
103+
104+
$searchCriteria = $this->searchCriteriaBuilder->create();
105+
$searchResults = $this->categoryRepository->getList($searchCriteria);
106+
107+
foreach ($searchResults->getItems() as $category) {
108+
$description = $category->getDescription() ? strip_tags($category->getDescription()) : '';
109+
$result[] = [
110+
'id' => sprintf('category/1/%d', $category->getId()),
111+
'type' => __('Category'),
112+
'name' => $category->getName(),
113+
'description' => $this->string->substr($description, 0, 30),
114+
'url' => $this->adminhtmlData->getUrl('catalog/category/edit', ['id' => $category->getId()]),
115+
];
116+
}
117+
$this->setResults($result);
118+
return $this;
119+
}
120+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCategorySearchTest">
12+
<annotations>
13+
<features value="Search Category"/>
14+
<stories value="Search categories in admin panel"/>
15+
<title value="Search for categories"/>
16+
<description value="Global search in backend can search into Categories."/>
17+
<severity value="MINOR"/>
18+
<group value="Search"/>
19+
<testCaseId value="MC-37809"/>
20+
</annotations>
21+
<before>
22+
<!-- Login as admin -->
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
25+
<!-- Create Simple Category -->
26+
<createData entity="SimpleSubCategory" stepKey="createSimpleCategory"/>
27+
</before>
28+
<after>
29+
<!-- Delete created category -->
30+
<deleteData createDataKey="createSimpleCategory" stepKey="deleteCreatedCategory"/>
31+
32+
<!-- Log out -->
33+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
34+
</after>
35+
<!-- Add created category name in the search field-->
36+
<actionGroup ref="AdminSetGlobalSearchValueActionGroup" stepKey="setSearch">
37+
<argument name="textSearch" value="$$createSimpleCategory.name$$"/>
38+
</actionGroup>
39+
40+
<!-- Wait for suggested results-->
41+
<waitForElementVisible selector="{{AdminGlobalSearchSection.globalSearchSuggestedCategoryText}}" stepKey="waitForSuggestions"/>
42+
43+
<!-- Click on suggested result in category URL-->
44+
<click selector="{{AdminGlobalSearchSection.globalSearchSuggestedCategoryLink}}" stepKey="openCategory"/>
45+
46+
<!-- Wait for suggested results-->
47+
<waitForPageLoad stepKey="waitForPageLoad"/>
48+
49+
<!-- Loaded page should be edit page of created category -->
50+
<seeInField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="$$createSimpleCategory.name$$" stepKey="checkCategoryName"/>
51+
</test>
52+
</tests>

app/code/Magento/CatalogSearch/etc/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
<item name="class" xsi:type="string">Magento\CatalogSearch\Model\Search\Catalog</item>
6767
<item name="acl" xsi:type="string">Magento_Catalog::catalog</item>
6868
</item>
69+
<item name="categories" xsi:type="array">
70+
<item name="class" xsi:type="string">Magento\CatalogSearch\Model\Search\Category</item>
71+
<item name="acl" xsi:type="string">Magento_Catalog::categories</item>
72+
</item>
6973
</argument>
7074
</arguments>
7175
</type>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressGridMainActionsSection.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<element name="multicheck" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>label"/>
1414
<element name="multicheckTick" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>input"/>
1515
<element name="delete" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Delete']"/>
16-
<element name="actions" type="text" selector=".action-select"/>
1716
<element name="customerCheckbox" type="button" selector="//*[contains(text(),'{{arg}}')]/parent::td/preceding-sibling::td/label[@class='data-grid-checkbox-cell-inner']//input" parameterized="true"/>
1817
<element name="ok" type="button" selector="//button[@data-role='action']//span[text()='OK']"/>
18+
<element name="addNewAddress" type="button" selector=".add-new-address-button" timeout="30"/>
19+
<element name="actions" type="text" selector=".admin__data-grid-header-row .action-select"/>
1920
</section>
2021
</sections>

app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@
2323
stepKey="enableLoginAsCustomer"/>
2424
<magentoCLI command="config:set {{LoginAsCustomerStoreViewLogin.path}} 0"
2525
stepKey="enableLoginAsCustomerAutoDetection"/>
26-
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
2726
<createData entity="_defaultCategory" stepKey="createCategory"/>
2827
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
2928
<requiredEntity createDataKey="createCategory"/>
3029
</createData>
3130
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
3231
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
32+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
33+
<argument name="indices" value=""/>
34+
</actionGroup>
35+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCachesAfterSet">
36+
<argument name="tags" value="config full_page"/>
37+
</actionGroup>
3338
</before>
3439
<after>
3540
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
@@ -39,7 +44,12 @@
3944
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
4045
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0"
4146
stepKey="disableLoginAsCustomer"/>
42-
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestRun"/>
47+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexAfter">
48+
<argument name="indices" value=""/>
49+
</actionGroup>
50+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCachesDefault">
51+
<argument name="tags" value="config full_page"/>
52+
</actionGroup>
4353
</after>
4454

4555
<!-- Verify Login as Customer Login action works correctly from Customer page -->

app/code/Magento/Sales/Helper/Guest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* Sales module base helper
1717
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1819
*/
1920
class Guest extends \Magento\Framework\App\Helper\AbstractHelper
2021
{
@@ -71,7 +72,7 @@ class Guest extends \Magento\Framework\App\Helper\AbstractHelper
7172
const COOKIE_NAME = 'guest-view';
7273

7374
/**
74-
* Cookie path
75+
* Cookie path value
7576
*/
7677
const COOKIE_PATH = '/';
7778

@@ -151,6 +152,7 @@ public function loadValidOrder(App\RequestInterface $request)
151152
return $this->resultRedirectFactory->create()->setPath('sales/order/history');
152153
}
153154
$post = $request->getPostValue();
155+
$post = filter_var($post, FILTER_CALLBACK, ['options' => 'trim']);
154156
$fromCookie = $this->cookieManager->getCookie(self::COOKIE_NAME);
155157
if (empty($post) && !$fromCookie) {
156158
return $this->resultRedirectFactory->create()->setPath('sales/guest/form');
@@ -224,6 +226,7 @@ private function setGuestViewCookie($cookieValue)
224226
*/
225227
private function loadFromCookie($fromCookie)
226228
{
229+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
227230
$cookieData = explode(':', base64_decode($fromCookie));
228231
$protectCode = isset($cookieData[0]) ? $cookieData[0] : null;
229232
$incrementId = isset($cookieData[1]) ? $cookieData[1] : null;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontFillOrdersAndReturnsFormTypeZipActionGroup">
12+
<arguments>
13+
<argument name="orderNumber" type="string"/>
14+
<argument name="customer" type="entity"/>
15+
<argument name="address" type="entity"/>
16+
</arguments>
17+
<fillField selector="{{StorefrontGuestOrderSearchSection.orderId}}" userInput="{{orderNumber}}" stepKey="inputOrderId"/>
18+
<fillField selector="{{StorefrontGuestOrderSearchSection.billingLastName}}" userInput="{{customer.lastname}}" stepKey="inputBillingLastName"/>
19+
<selectOption selector="{{StorefrontGuestOrderSearchSection.findOrderBy}}" userInput="zip" stepKey="selectFindOrderByZip"/>
20+
<fillField selector="{{StorefrontGuestOrderSearchSection.zip}}" userInput="{{address.postcode}}" stepKey="inputZip"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Sales/Test/Mftf/Section/StorefrontGuestOrderSearchSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="billingLastName" type="input" selector="#oar-billing-lastname"/>
1414
<element name="findOrderBy" type="select" selector="#quick-search-type-id"/>
1515
<element name="email" type="input" selector="#oar_email"/>
16+
<element name="zip" type="input" selector="#oar_zip"/>
1617
<element name="continue" type="button" selector="//*/span[contains(text(), 'Continue')]"/>
1718
</section>
1819
</sections>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontPrintOrderFindByZipGuestTest" extends="StorefrontPrintOrderGuestTest">
12+
<annotations>
13+
<stories value="Print Order"/>
14+
<title value="Print Order from Guest on Frontend using Zip for search"/>
15+
<description value="Print Order from Guest on Frontend"/>
16+
<severity value="MINOR"/>
17+
<testCaseId value="MC-37449"/>
18+
<group value="sales"/>
19+
</annotations>
20+
21+
<remove keyForRemoval="fillOrder"/>
22+
23+
<!-- Fill the form with correspondent Order data using search by Zip -->
24+
<actionGroup ref="StorefrontFillOrdersAndReturnsFormTypeZipActionGroup" stepKey="fillOrderZip" before="clickContinue">
25+
<argument name="orderNumber" value="{$getOrderId}"/>
26+
<argument name="customer" value="$$createCustomer$$"/>
27+
<argument name="address" value="US_Address_TX"/>
28+
</actionGroup>
29+
</test>
30+
</tests>

0 commit comments

Comments
 (0)