Skip to content

Commit 6c92add

Browse files
authored
Merge branch '2.4-develop' into unlock-admin-user
2 parents 7cf5fee + ac88ad9 commit 6c92add

File tree

120 files changed

+3968
-963
lines changed

Some content is hidden

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

120 files changed

+3968
-963
lines changed

app/code/Magento/AdvancedSearch/Model/ResourceModel/Index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public function __construct(
8080

8181
/**
8282
* Implementation of abstract construct
83+
*
8384
* @return void
8485
* @since 100.1.0
86+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
8587
*/
8688
protected function _construct()
8789
{
@@ -118,7 +120,8 @@ protected function _getCatalogProductPriceData($productIds = null)
118120

119121
$result = [];
120122
foreach ($connection->fetchAll($catalogProductIndexPriceUnionSelect) as $row) {
121-
$result[$row['website_id']][$row['entity_id']][$row['customer_group_id']] = round($row['min_price'], 2);
123+
$result[$row['website_id']][$row['entity_id']][$row['customer_group_id']] =
124+
round((float) $row['min_price'], 2);
122125
}
123126

124127
return $result;

app/code/Magento/AdvancedSearch/Test/Unit/Model/ResourceModel/IndexTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class IndexTest extends TestCase
6060
*/
6161
private $resourceConnectionMock;
6262

63+
/**
64+
* @inheritdoc
65+
*/
6366
protected function setUp(): void
6467
{
6568
$this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
@@ -98,6 +101,9 @@ protected function setUp(): void
98101
);
99102
}
100103

104+
/**
105+
* @return void
106+
*/
101107
public function testGetPriceIndexDataUsesFrontendPriceIndexerTable(): void
102108
{
103109
$storeId = 1;
@@ -117,4 +123,73 @@ public function testGetPriceIndexDataUsesFrontendPriceIndexerTable(): void
117123

118124
$this->assertEmpty($this->model->getPriceIndexData([1], $storeId));
119125
}
126+
127+
/**
128+
* @param array $testData
129+
* @dataProvider providerForTestPriceIndexData
130+
*
131+
* @return void
132+
*/
133+
public function testGetPriceIndexData(array $testData): void
134+
{
135+
$storeMock = $this->getMockForAbstractClass(StoreInterface::class);
136+
$storeMock->expects($this->any())->method('getId')->willReturn(1);
137+
$storeMock->method('getWebsiteId')->willReturn($testData['website_id']);
138+
$this->storeManagerMock->expects($this->once())
139+
->method('getStore')
140+
->with(1)->willReturn($storeMock);
141+
142+
$selectMock = $this->createMock(Select::class);
143+
$selectMock->expects($this->any())->method('union')->willReturnSelf();
144+
$this->adapterMock->expects($this->any())->method('select')->willReturn($selectMock);
145+
$this->adapterMock->expects($this->any())->method('fetchAll')->with($selectMock)->willReturn([$testData]);
146+
$expectedData = [
147+
$testData['entity_id'] => [
148+
$testData['customer_group_id'] => round((float) $testData['min_price'], 2)
149+
]
150+
];
151+
152+
$this->assertEquals($this->model->getPriceIndexData([1], 1), $expectedData);
153+
}
154+
155+
/**
156+
* @return array
157+
*/
158+
public function providerForTestPriceIndexData(): array
159+
{
160+
return [
161+
[
162+
[
163+
'website_id' => 1,
164+
'entity_id' => 1,
165+
'customer_group_id' => 1,
166+
'min_price' => '12.12'
167+
]
168+
],
169+
[
170+
[
171+
'website_id' => 1,
172+
'entity_id' => 2,
173+
'customer_group_id' => 2,
174+
'min_price' => null
175+
]
176+
],
177+
[
178+
[
179+
'website_id' => 1,
180+
'entity_id' => 3,
181+
'customer_group_id' => 3,
182+
'min_price' => 12.12
183+
]
184+
],
185+
[
186+
[
187+
'website_id' => 1,
188+
'entity_id' => 3,
189+
'customer_group_id' => 3,
190+
'min_price' => ''
191+
]
192+
]
193+
];
194+
}
120195
}

app/code/Magento/Backend/view/adminhtml/templates/widget/form/container.phtml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
3333
require([
3434
'jquery',
35-
'mage/backend/form',
36-
'mage/backend/validation'
35+
'mage/mage'
3736
], function($){
3837
39-
$('#edit_form').form()
40-
.validation({
38+
$('#edit_form').mage('form').mage('validation', {
4139
validationUrl: '{$block->escapeJs($block->getValidationUrl())}',
4240
highlight: function(element) {
4341
var detailsElement = $(element).closest('details');
@@ -49,8 +47,7 @@ require([
4947
}
5048
$(element).trigger('highlight.validate');
5149
}
52-
});
53-
50+
});
5451
});
5552
5653
script;

app/code/Magento/Bundle/Model/Product/SelectionProductsDisabledRequired.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function __construct(
8282
* @param int $bundleId
8383
* @param int|null $websiteId
8484
* @return array
85+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8586
*/
8687
public function getChildProductIds(int $bundleId, ?int $websiteId = null): array
8788
{
@@ -128,10 +129,12 @@ public function getChildProductIds(int $bundleId, ?int $websiteId = null): array
128129
private function getProducts(array $selectionProductIds, int $websiteId): array
129130
{
130131
$productIds = [];
131-
$defaultStoreId = $this->storeManager->getWebsite($websiteId)->getDefaultStore()->getId();
132+
$defaultStore = $this->storeManager->getWebsite($websiteId)->getDefaultStore();
133+
$defaultStoreId = $defaultStore ? $defaultStore->getId() : null;
132134
foreach ($selectionProductIds as $optionProductIds) {
133-
$productIds = array_merge($productIds, $optionProductIds);
135+
$productIds[] = $optionProductIds;
134136
}
137+
$productIds = array_merge([], ...$productIds);
135138
$productCollection = $this->productCollectionFactory->create();
136139
$productCollection->joinAttribute(
137140
ProductInterface::STATUS,

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\Store\Model\StoreManagerInterface;
1313

1414
/**
15-
* Class Save
15+
* Category save controller
1616
*
1717
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1818
*/
@@ -144,10 +144,10 @@ public function execute()
144144
$categoryPostData = $this->stringToBoolConverting($categoryPostData);
145145
$categoryPostData = $this->imagePreprocessing($categoryPostData);
146146
$categoryPostData = $this->dateTimePreprocessing($category, $categoryPostData);
147-
$storeId = isset($categoryPostData['store_id']) ? $categoryPostData['store_id'] : null;
147+
$storeId = $categoryPostData['store_id'] ?? null;
148148
$store = $this->storeManager->getStore($storeId);
149149
$this->storeManager->setCurrentStore($store->getCode());
150-
$parentId = isset($categoryPostData['parent']) ? $categoryPostData['parent'] : null;
150+
$parentId = $categoryPostData['parent'] ?? null;
151151
if ($categoryPostData) {
152152
$category->addData($categoryPostData);
153153
if ($parentId) {
@@ -168,7 +168,7 @@ public function execute()
168168
if (isset($categoryPostData['use_config']) && !empty($categoryPostData['use_config'])) {
169169
foreach ($categoryPostData['use_config'] as $attributeCode => $attributeValue) {
170170
if ($attributeValue) {
171-
$useConfig[] = $attributeCode;
171+
$useConfig[] = $attributeValue;
172172
$category->setData($attributeCode, null);
173173
}
174174
}
@@ -220,7 +220,11 @@ public function execute()
220220
__('The "%1" attribute is required. Enter and try again.', $attribute)
221221
);
222222
} else {
223-
$this->messageManager->addErrorMessage(__('Something went wrong while saving the category.'));
223+
$this->messageManager->addErrorMessage(
224+
__(
225+
'Something went wrong while saving the category.'
226+
)
227+
);
224228
$this->logger->critical('Something went wrong while saving the category.');
225229
$this->_getSession()->setCategoryData($categoryPostData);
226230
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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="AdminNavigateToProductAttributeEditPageActionGroup">
12+
<annotations>
13+
<description>Navigate to the given product attribute edit page by attribute label</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="ProductAttributeLabel" type="string"/>
17+
</arguments>
18+
19+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
20+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="{{ProductAttributeLabel}}" stepKey="fillTheAttributesFilterByLabel"/>
21+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="clickTheSearchButton"/>
22+
<waitForPageLoad stepKey="waitForSearchToComplete"/>
23+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnTheFirstSearchResultRow"/>
24+
<waitForPageLoad stepKey="waitForAttribiteEditPageToLoad"/>
25+
</actionGroup>
26+
</actionGroups>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="StorefrontCategoryFilterSection">
12-
<element name="CategoryFilter" type="button" selector="//main//div[@class='filter-options']//div[contains(text(), 'Category')]"/>
12+
<element name="CategoryFilter" type="button" selector="//main//div[contains(@class,'filter-options')]//div[contains(text(), 'Category')]"/>
1313
<element name="CategoryByName" type="button" selector="//main//div[@class='filter-options']//li[@class='item']//a[contains(text(), '{{var1}}')]" parameterized="true"/>
1414
</section>
1515
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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="AdminScopeSelectionShouldBeDisabledOnMediaGalleryProductAttributeEditTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Attributes Updating"/>
14+
<group value="Catalog"/>
15+
<title value="Admin should not able to change Scope of Media Gallery product attribute"/>
16+
<description value="Admin should not able to change Scope of Media Gallery product attribute"/>
17+
<severity value="MAJOR"/>
18+
<useCaseId value="MC-38156"/>
19+
<testCaseId value="AC-1337"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
26+
</after>
27+
28+
<actionGroup ref="AdminNavigateToProductAttributeEditPageActionGroup" stepKey="navigateToMediaGalleryProductAttribute">
29+
<argument name="ProductAttributeLabel" value="Media Gallery"/>
30+
</actionGroup>
31+
32+
<click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="clickAdvancedAttributePropertiesSectionToggle"/>
33+
34+
<assertElementContainsAttribute stepKey="assertTheScopeSelectionIsDisabled">
35+
<expectedResult selector="{{AdvancedAttributePropertiesSection.Scope}}" attribute="disabled" type="string"></expectedResult>
36+
</assertElementContainsAttribute>
37+
38+
</test>
39+
</tests>
40+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\CatalogGraphQl\Model;
9+
10+
use Magento\Framework\Exception\NoSuchEntityException;
11+
use Magento\Framework\Stdlib\StringUtils as StdlibString;
12+
use Magento\GraphQl\Model\Query\ContextInterface;
13+
use Magento\Search\Model\Query;
14+
use Magento\Search\Model\QueryFactory;
15+
16+
/**
17+
* Prepares search query based on search text.
18+
*/
19+
class QueryProcessor
20+
{
21+
/**
22+
* @var QueryFactory
23+
*/
24+
private $queryFactory;
25+
26+
/**
27+
* @var StdlibString
28+
*/
29+
private $string;
30+
31+
/**
32+
* @param QueryFactory $queryFactory
33+
* @param StdlibString $string
34+
*/
35+
public function __construct(
36+
QueryFactory $queryFactory,
37+
StdlibString $string
38+
) {
39+
$this->queryFactory = $queryFactory;
40+
$this->string = $string;
41+
}
42+
43+
/**
44+
* Prepare Query object based on search text
45+
*
46+
* @param ContextInterface $context
47+
* @param string $queryText
48+
* @throws NoSuchEntityException
49+
* @return Query
50+
*/
51+
public function prepare(ContextInterface $context, string $queryText) : Query
52+
{
53+
$query = $this->queryFactory->create();
54+
$maxQueryLength = (int) $query->getMaxQueryLength();
55+
if ($maxQueryLength && $this->string->strlen($queryText) > $maxQueryLength) {
56+
$queryText = $this->string->substr($queryText, 0, $maxQueryLength);
57+
}
58+
$query->setQueryText($queryText);
59+
$store = $context->getExtensionAttributes()->getStore();
60+
$query->setStoreId($store->getId());
61+
return $query;
62+
}
63+
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function resolve(
7070
$data = [
7171
'total_count' => $searchResult->getTotalCount(),
7272
'items' => $searchResult->getProductsSearchResult(),
73+
'suggestions' => $searchResult->getSuggestions(),
7374
'page_info' => [
7475
'page_size' => $searchResult->getPageSize(),
7576
'current_page' => $searchResult->getCurrentPage(),

0 commit comments

Comments
 (0)