Skip to content

Commit cd534d8

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into 2.4-develop-pr39
2 parents 383704d + 0333859 commit cd534d8

File tree

216 files changed

+3788
-17209
lines changed

Some content is hidden

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

216 files changed

+3788
-17209
lines changed

app/code/Magento/AdvancedSearch/Model/Client/ClientResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*/
66
namespace Magento\AdvancedSearch\Model\Client;
77

8-
use \Magento\Framework\ObjectManagerInterface;
8+
use Magento\Framework\ObjectManagerInterface;
99
use Magento\Framework\Search\EngineResolverInterface;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
1011

1112
/**
1213
* @api
@@ -46,7 +47,7 @@ class ClientResolver
4647
private $clientOptionsPool;
4748

4849
/**
49-
* @var EngineResolver
50+
* @var EngineResolverInterface
5051
*/
5152
private $engineResolver;
5253

app/code/Magento/AdvancedSearch/Model/Indexer/Fulltext/Plugin/CustomerGroup.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use Magento\Framework\Model\AbstractModel;
1313
use Magento\Catalog\Model\ResourceModel\Attribute;
1414
use Magento\AdvancedSearch\Model\Client\ClientOptionsInterface;
15-
use Magento\Framework\Search\EngineResolverInterface;
16-
use Magento\Search\Model\EngineResolver;
1715

1816
class CustomerGroup extends AbstractPlugin
1917
{
@@ -22,24 +20,16 @@ class CustomerGroup extends AbstractPlugin
2220
*/
2321
protected $clientOptions;
2422

25-
/**
26-
* @var EngineResolverInterface
27-
*/
28-
protected $engineResolver;
29-
3023
/**
3124
* @param IndexerRegistry $indexerRegistry
3225
* @param ClientOptionsInterface $clientOptions
33-
* @param EngineResolverInterface $engineResolver
3426
*/
3527
public function __construct(
3628
IndexerRegistry $indexerRegistry,
37-
ClientOptionsInterface $clientOptions,
38-
EngineResolverInterface $engineResolver
29+
ClientOptionsInterface $clientOptions
3930
) {
4031
parent::__construct($indexerRegistry);
4132
$this->clientOptions = $clientOptions;
42-
$this->engineResolver = $engineResolver;
4333
}
4434

4535
/**
@@ -56,9 +46,7 @@ public function aroundSave(
5646
\Closure $proceed,
5747
AbstractModel $group
5848
) {
59-
$needInvalidation =
60-
($this->engineResolver->getCurrentSearchEngine() != EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE)
61-
&& ($group->isObjectNew() || $group->dataHasChangedFor('tax_class_id'));
49+
$needInvalidation = $group->isObjectNew() || $group->dataHasChangedFor('tax_class_id');
6250
$result = $proceed($group);
6351
if ($needInvalidation) {
6452
$this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();

app/code/Magento/AdvancedSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/CustomerGroupTest.php

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use Magento\Customer\Model\ResourceModel\Group as CustomerGroupResourceModel;
1515
use Magento\Framework\Indexer\IndexerInterface;
1616
use Magento\Framework\Indexer\IndexerRegistry;
17-
use Magento\Framework\Search\EngineResolverInterface;
1817
use PHPUnit\Framework\TestCase;
18+
use PHPUnit\Framework\MockObject\MockObject;
1919

2020
/**
2121
* @covers \Magento\AdvancedSearch\Model\Indexer\Fulltext\Plugin\CustomerGroup
@@ -35,7 +35,7 @@ class CustomerGroupTest extends TestCase
3535
private $indexerMock;
3636

3737
/**
38-
* @var Group|MockObject
38+
* @var CustomerGroupResourceModel|MockObject
3939
*/
4040
private $subjectMock;
4141

@@ -49,11 +49,6 @@ class CustomerGroupTest extends TestCase
4949
*/
5050
private $indexerRegistryMock;
5151

52-
/**
53-
* @var EngineResolverInterface|MockObject
54-
*/
55-
private $engineResolverMock;
56-
5752
protected function setUp(): void
5853
{
5954
$this->subjectMock = $this->createMock(CustomerGroupResourceModel::class);
@@ -73,35 +68,24 @@ protected function setUp(): void
7368
IndexerRegistry::class,
7469
['get']
7570
);
76-
$this->engineResolverMock = $this->createPartialMock(
77-
EngineResolverInterface::class,
78-
['getCurrentSearchEngine']
79-
);
8071
$this->model = new CustomerGroupPlugin(
8172
$this->indexerRegistryMock,
82-
$this->customerOptionsMock,
83-
$this->engineResolverMock
73+
$this->customerOptionsMock
8474
);
8575
}
8676

8777
/**
88-
* @param string $searchEngine
8978
* @param bool $isObjectNew
9079
* @param bool $isTaxClassIdChanged
9180
* @param int $invalidateCounter
9281
* @return void
9382
* @dataProvider aroundSaveDataProvider
9483
*/
9584
public function testAroundSave(
96-
string $searchEngine,
9785
bool $isObjectNew,
9886
bool $isTaxClassIdChanged,
9987
int $invalidateCounter
10088
): void {
101-
$this->engineResolverMock->expects($this->once())
102-
->method('getCurrentSearchEngine')
103-
->willReturn($searchEngine);
104-
10589
$groupMock = $this->createPartialMock(
10690
CustomerGroupModel::class,
10791
['dataHasChangedFor', 'isObjectNew', '__wakeup']
@@ -137,14 +121,10 @@ public function testAroundSave(
137121
public function aroundSaveDataProvider(): array
138122
{
139123
return [
140-
['mysql', false, false, 0],
141-
['mysql', false, true, 0],
142-
['mysql', true, false, 0],
143-
['mysql', true, true, 0],
144-
['custom', false, false, 0],
145-
['custom', false, true, 1],
146-
['custom', true, false, 1],
147-
['custom', true, true, 1],
124+
[false, false, 0],
125+
[false, true, 1],
126+
[true, false, 1],
127+
[true, true, 1],
148128
];
149129
}
150130
}

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<group value="Bundle"/>
2020
<group value="SearchEngineElasticsearch"/>
2121
<skip>
22-
<issueId value="MC-21228"/>
22+
<issueId value="MC-34217"/>
2323
</skip>
2424
</annotations>
2525
<before>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
3636
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
3737
</entity>
38+
<entity name="ApiSimpleProductWithNoSpace" type="product" extends="ApiSimpleProduct">
39+
<data key="name">TestFooBar</data>
40+
<data key="sku" unique="suffix">foobar</data>
41+
</entity>
3842
<entity name="ApiSimpleProductWithSpecCharInName" type="product" extends="ApiSimpleProduct">
3943
<data key="name">Pursuit Lumaflex&#38;trade; Tone Band</data>
4044
<data key="sku" unique="suffix">x&#38;trade;</data>
@@ -68,6 +72,9 @@
6872
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
6973
<requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity>
7074
</entity>
75+
<entity name="ProductForPartialSearch" extends="SimpleProduct" type="product">
76+
<data key="sku">partialTestSku</data>
77+
</entity>
7178
<entity name="ProductWithSpecialSymbols" extends="SimpleProduct" type="product">
7279
<data key="name">SimpleProduct -+~/\\&lt;&gt;\’“:*\$#@()!,.?`=%&amp;^</data>
7380
</entity>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchSimpleProductBySkuWithHyphenTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<group value="Catalog"/>
2020
<group value="SearchEngineElasticsearch"/>
2121
<skip>
22-
<issueId value="MC-21228"/>
22+
<issueId value="MC-34217"/>
2323
</skip>
2424
</annotations>
2525
<before>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchVirtualProductBySkuWithHyphenTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<group value="Catalog"/>
2020
<group value="SearchEngineElasticsearch"/>
2121
<skip>
22-
<issueId value="MC-21228"/>
22+
<issueId value="MC-34217"/>
2323
</skip>
2424
</annotations>
2525
<before>

app/code/Magento/CatalogCmsGraphQl/Model/Resolver/Category/Block.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Exception\LocalizedException;
1212
use Magento\Framework\Exception\NoSuchEntityException;
1313
use Magento\Framework\GraphQl\Config\Element\Field;
14+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1415
use Magento\Framework\GraphQl\Query\ResolverInterface;
1516
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1617
use Magento\CmsGraphQl\Model\Resolver\DataProvider\Block as BlockProvider;
@@ -48,18 +49,19 @@ public function resolve(
4849
}
4950
/** @var Category $category */
5051
$category = $value['model'];
51-
$blockId = $category->getLandingPage();
52+
$blockId = (int)$category->getLandingPage();
53+
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
5254

5355
if (empty($blockId)) {
5456
return null;
5557
}
5658

5759
try {
58-
$block = $this->blockProvider->getData($blockId);
60+
$blockData = $this->blockProvider->getBlockById($blockId, $storeId);
5961
} catch (NoSuchEntityException $e) {
60-
return null;
62+
return new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
6163
}
6264

63-
return $block;
65+
return $blockData;
6466
}
6567
}

app/code/Magento/CatalogGraphQl/Model/Category/CategoryFilter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\Framework\Exception\InputException;
1414
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1515
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Filter;
16-
use Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match;
1716
use Magento\Search\Model\Query;
1817
use Magento\Store\Api\Data\StoreInterface;
1918
use Magento\Store\Model\ScopeInterface;
@@ -24,6 +23,11 @@
2423
*/
2524
class CategoryFilter
2625
{
26+
/**
27+
* @var string
28+
*/
29+
private const SPECIAL_CHARACTERS = '-+~/\\<>\'":*$#@()!,.?`=%&^';
30+
2731
/**
2832
* @var ScopeConfigInterface
2933
*/
@@ -120,7 +124,7 @@ private function formatMatchFilters(array $filters, StoreInterface $store): arra
120124
foreach ($filters as $filter => $condition) {
121125
$conditionType = current(array_keys($condition));
122126
if ($conditionType === 'match') {
123-
$searchValue = trim(str_replace(Match::SPECIAL_CHARACTERS, '', $condition[$conditionType]));
127+
$searchValue = trim(str_replace(self::SPECIAL_CHARACTERS, '', $condition[$conditionType]));
124128
$matchLength = strlen($searchValue);
125129
if ($matchLength < $minQueryLength) {
126130
throw new InputException(__('Invalid match filter. Minimum length is %1.', $minQueryLength));

app/code/Magento/CatalogGraphQl/Model/Search/Adapter/Mysql/Query/Builder/Match.php

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

app/code/Magento/CatalogGraphQl/etc/graphql/di.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
9191
</argument>
9292
</arguments>
9393
</virtualType>
94-
<preference for="Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match"
95-
type="Magento\CatalogGraphQl\Model\Search\Adapter\Mysql\Query\Builder\Match" />
9694
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
9795
<arguments>
9896
<argument name="extendedConfigData" xsi:type="array">

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ interface CategoryInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model
245245
level: Int @doc(description: "Indicates the depth of the category within the tree.")
246246
created_at: String @doc(description: "Timestamp indicating when the category was created.")
247247
updated_at: String @doc(description: "Timestamp indicating when the category was updated.")
248-
product_count: Int @doc(description: "The number of products in the category.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\ProductsCount")
248+
product_count: Int @doc(description: "The number of products in the category that are marked as visible. By default, in complex products, parent products are visible, but their child products are not.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\ProductsCount")
249249
default_sort_by: String @doc(description: "The attribute to use for sorting.")
250250
products(
251251
pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. This attribute is optional."),
@@ -299,7 +299,7 @@ type SimpleProduct implements ProductInterface, PhysicalProductInterface, Custom
299299
type Products @doc(description: "The Products object is the top-level object returned in a product search.") {
300300
items: [ProductInterface] @doc(description: "An array of products that match the specified search criteria.")
301301
page_info: SearchResultPageInfo @doc(description: "An object that includes the page_info and currentPage values specified in the query.")
302-
total_count: Int @doc(description: "The number of products returned.")
302+
total_count: Int @doc(description: "The number of products that are marked as visible. By default, in complex products, parent products are visible, but their child products are not.")
303303
filters: [LayerFilter] @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\LayerFilters") @doc(description: "Layered navigation filters array.") @deprecated(reason: "Use aggregations instead")
304304
aggregations: [Aggregation] @doc(description: "Layered navigation aggregations.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Aggregations")
305305
sort_fields: SortFields @doc(description: "An object that includes the default sort field and all available sort fields.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\SortFields")
@@ -308,7 +308,7 @@ type Products @doc(description: "The Products object is the top-level object ret
308308
type CategoryProducts @doc(description: "The category products object returned in the Category query.") {
309309
items: [ProductInterface] @doc(description: "An array of products that are assigned to the category.")
310310
page_info: SearchResultPageInfo @doc(description: "An object that includes the page_info and currentPage values specified in the query.")
311-
total_count: Int @doc(description: "The number of products returned.")
311+
total_count: Int @doc(description: "The number of products in the category that are marked as visible. By default, in complex products, parent products are visible, but their child products are not.")
312312
}
313313

314314
input ProductAttributeFilterInput @doc(description: "ProductAttributeFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.") {

0 commit comments

Comments
 (0)