Skip to content

Commit 8afc4c9

Browse files
authored
Merge branch '2.4-develop' into 2.4-develop-prs
2 parents da8fe0e + 5b2f325 commit 8afc4c9

File tree

55 files changed

+3119
-305
lines changed

Some content is hidden

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

55 files changed

+3119
-305
lines changed

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/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.") {

app/code/Magento/CatalogGraphQl/etc/search_request.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<queries>
1616
<query xsi:type="boolQuery" name="graphql_product_search_with_aggregation" boost="1">
1717
<queryReference clause="should" ref="search" />
18+
<queryReference clause="should" ref="partial_search" />
1819
<queryReference clause="must" ref="category"/>
1920
<queryReference clause="must" ref="price"/>
2021
<queryReference clause="must" ref="visibility"/>
@@ -23,6 +24,11 @@
2324
<match field="sku"/>
2425
<match field="*"/>
2526
</query>
27+
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
28+
<match field="*"/>
29+
<match field="name" matchCondition="match_phrase_prefix"/>
30+
<match field="sku" matchCondition="match_phrase_prefix"/>
31+
</query>
2632
<query name="category" xsi:type="filteredQuery">
2733
<filterReference clause="must" ref="category_filter"/>
2834
</query>
@@ -61,6 +67,7 @@
6167
<queries>
6268
<query xsi:type="boolQuery" name="graphql_product_search" boost="1">
6369
<queryReference clause="should" ref="search" />
70+
<queryReference clause="should" ref="partial_search" />
6471
<queryReference clause="must" ref="category"/>
6572
<queryReference clause="must" ref="price"/>
6673
<queryReference clause="must" ref="visibility"/>
@@ -69,6 +76,11 @@
6976
<match field="sku"/>
7077
<match field="*"/>
7178
</query>
79+
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
80+
<match field="*"/>
81+
<match field="name" matchCondition="match_phrase_prefix"/>
82+
<match field="sku" matchCondition="match_phrase_prefix"/>
83+
</query>
7284
<query name="category" xsi:type="filteredQuery">
7385
<filterReference clause="must" ref="category_filter"/>
7486
</query>

app/code/Magento/CatalogSearch/Test/Mftf/Test/MinimalQueryLengthForCatalogSearchTest.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
<useCaseId value="MAGETWO-58764"/>
2020
<group value="CatalogSearch"/>
2121
<group value="SearchEngineElasticsearch"/>
22-
<skip>
23-
<issueId value="MC-21228"/>
24-
</skip>
22+
2523
</annotations>
2624
<before>
2725
<createData entity="ApiCategory" stepKey="createCategory"/>
28-
<createData entity="ApiSimpleProduct" stepKey="createProduct">
26+
<createData entity="productAlphabeticalB" stepKey="createProduct">
2927
<requiredEntity createDataKey="createCategory"/>
3028
</createData>
3129
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
@@ -39,7 +37,8 @@
3937
<actionGroup ref="SetMinimalQueryLengthActionGroup" stepKey="setMinQueryLength"/>
4038
<comment userInput="Go to Storefront and search for product" stepKey="searchProdUsingMinQueryLength"/>
4139
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
42-
<fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="s" stepKey="fillAttribute"/>
40+
<comment userInput="Quick search by single character and avoid using ES stopwords" stepKey="commentQuickSearch"/>
41+
<fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="B" stepKey="fillAttribute"/>
4342
<waitForPageLoad stepKey="waitForSearchTextBox"/>
4443
<click selector="{{StorefrontQuickSearchResultsSection.searchTextBoxButton}}" stepKey="clickSearchTextBoxButton"/>
4544
<waitForPageLoad stepKey="waitForSearch"/>

app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest/QuickSearchProductByNameWithThreeLettersTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<group value="CatalogSearch"/>
1818
<group value="SearchEngineElasticsearch"/>
1919
<group value="mtf_migrated"/>
20-
<skip>
21-
<issueId value="MC-21228"/>
22-
</skip>
2320
</annotations>
2421
<executeJS function="var s = '$createSimpleProduct.name$'; var ret=s.substring(0,3); return ret;" stepKey="getFirstThreeLetters" before="searchStorefront"/>
2522
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchStorefront">

app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest/QuickSearchTwoProductsWithSameWeightTest.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<group value="CatalogSearch"/>
1818
<group value="SearchEngineElasticsearch"/>
1919
<group value="mtf_migrated"/>
20-
<skip>
21-
<issueId value="MC-21228"/>
22-
</skip>
2320
</annotations>
2421
<before>
2522
<createData entity="_defaultCategory" stepKey="createCategory"/>
@@ -31,7 +28,6 @@
3128
</createData>
3229
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
3330

34-
3531
<!-- Create and Assign Attribute to product1-->
3632
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToProduct1">
3733
<argument name="productId" value="$product1.id$"/>
@@ -79,18 +75,19 @@
7975
<deleteData stepKey="deleteProduct1" createDataKey="product1"/>
8076
<deleteData stepKey="deleteProduct2" createDataKey="product2"/>
8177
<deleteData stepKey="deleteCategory" createDataKey="createCategory"/>
78+
8279
</after>
8380
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToFrontPage"/>
8481
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchStorefront">
8582
<argument name="phrase" value="{{_defaultProduct.name}}"/>
8683
</actionGroup>
8784
<actionGroup ref="StorefrontQuickSearchCheckProductNameInGridActionGroup" stepKey="assertProduct1Position">
8885
<argument name="productName" value="$product1.name$"/>
89-
<argument name="index" value="2"/>
86+
<argument name="index" value="1"/>
9087
</actionGroup>
9188
<actionGroup ref="StorefrontQuickSearchCheckProductNameInGridActionGroup" stepKey="assertProduct2Position">
9289
<argument name="productName" value="$product2.name$"/>
93-
<argument name="index" value="1"/>
90+
<argument name="index" value="2"/>
9491
</actionGroup>
9592
</test>
9693
</tests>

app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialNameTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<group value="mtf_migrated"/>
2020
<group value="SearchEngineElasticsearch"/>
2121
<skip>
22-
<issueId value="MC-21228"/>
22+
<issueId value="MC-34217"/>
2323
</skip>
2424
</annotations>
2525
<actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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="StorefrontPartialWordQuickSearchUsingElasticSearchTest">
12+
<annotations>
13+
<features value="Search"/>
14+
<stories value="Partial Word search using Elasticsearch"/>
15+
<title value="Support partial word search in Elasticsearch"/>
16+
<description value="Support quick search with Partial word search using ES"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-34205"/>
19+
<group value="SearchEngineElasticsearch"/>
20+
</annotations>
21+
<before>
22+
<!-- Create subcategory -->
23+
<createData entity="SimpleSubCategory" stepKey="newCategory"/>
24+
<createData entity="ProductForPartialSearch" stepKey="product1">
25+
<requiredEntity createDataKey="newCategory"/>
26+
</createData>
27+
<createData entity="ApiSimpleProduct" stepKey="product2">
28+
<requiredEntity createDataKey="newCategory"/>
29+
</createData>
30+
<createData entity="ApiSimpleProductWithNoSpace" stepKey="product3">
31+
<requiredEntity createDataKey="newCategory"/>
32+
</createData>
33+
</before>
34+
<after>
35+
<deleteData createDataKey="product1" stepKey="deleteProduct1"/>
36+
<deleteData createDataKey="product2" stepKey="deleteProduct2"/>
37+
<deleteData createDataKey="product3" stepKey="deleteProduct3"/>
38+
<deleteData createDataKey="newCategory" stepKey="deleteCategory"/>
39+
</after>
40+
41+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/>
42+
43+
<!--Perform a quick seach using a partial word from product SKU-->
44+
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchPartialSku">
45+
<argument name="phrase" value="partial"/>
46+
</actionGroup>
47+
48+
<!--Perform a case insensitive quick search of partial word using case product name -->
49+
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchPartialCaseInSensitive">
50+
<argument name="phrase" value="simple"/>
51+
</actionGroup>
52+
<!--Perform a quick search using parts of the words from name/sku with additional characters-->
53+
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchPartialWordsWithExtraChars">
54+
<argument name="phrase" value="barstool"/>
55+
</actionGroup>
56+
<actionGroup ref="StorefrontCheckSearchIsEmptyActionGroup" stepKey="checkEmptySearchResult"/>
57+
58+
</test>
59+
</tests>
60+

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414
<queries>
1515
<query xsi:type="boolQuery" name="quick_search_container" boost="1">
1616
<queryReference clause="should" ref="search" />
17+
<queryReference clause="should" ref="partial_search" />
1718
<queryReference clause="must" ref="category"/>
1819
<queryReference clause="must" ref="price"/>
1920
<queryReference clause="must" ref="visibility"/>
2021
</query>
2122
<query xsi:type="matchQuery" value="$search_term$" name="search">
2223
<match field="*"/>
2324
</query>
25+
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
26+
<match field="*"/>
27+
<match field="name" matchCondition="match_phrase_prefix"/>
28+
<match field="sku" matchCondition="match_phrase_prefix"/>
29+
</query>
2430
<query xsi:type="filteredQuery" name="category">
2531
<filterReference clause="must" ref="category_filter"/>
2632
</query>

app/code/Magento/CmsGraphQl/Model/Resolver/Blocks.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17+
use function is_numeric;
1718

1819
/**
1920
* CMS blocks field resolver, used for GraphQL request processing
@@ -44,14 +45,13 @@ public function resolve(
4445
array $value = null,
4546
array $args = null
4647
) {
47-
48+
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
4849
$blockIdentifiers = $this->getBlockIdentifiers($args);
49-
$blocksData = $this->getBlocksData($blockIdentifiers);
50+
$blocksData = $this->getBlocksData($blockIdentifiers, $storeId);
5051

51-
$resultData = [
52+
return [
5253
'items' => $blocksData,
5354
];
54-
return $resultData;
5555
}
5656

5757
/**
@@ -74,15 +74,22 @@ private function getBlockIdentifiers(array $args): array
7474
* Get blocks data
7575
*
7676
* @param array $blockIdentifiers
77+
* @param int $storeId
7778
* @return array
7879
* @throws GraphQlNoSuchEntityException
7980
*/
80-
private function getBlocksData(array $blockIdentifiers): array
81+
private function getBlocksData(array $blockIdentifiers, int $storeId): array
8182
{
8283
$blocksData = [];
8384
foreach ($blockIdentifiers as $blockIdentifier) {
8485
try {
85-
$blocksData[$blockIdentifier] = $this->blockDataProvider->getData($blockIdentifier);
86+
if (!is_numeric($blockIdentifier)) {
87+
$blocksData[$blockIdentifier] = $this->blockDataProvider
88+
->getBlockByIdentifier($blockIdentifier, $storeId);
89+
} else {
90+
$blocksData[$blockIdentifier] = $this->blockDataProvider
91+
->getBlockById((int)$blockIdentifier, $storeId);
92+
}
8693
} catch (NoSuchEntityException $e) {
8794
$blocksData[$blockIdentifier] = new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
8895
}

0 commit comments

Comments
 (0)