Skip to content

Commit ddf76d3

Browse files
committed
MAGETWO-73989: [GitHub] Minimal Query Length For Catalog Search #6681
1 parent a1daa45 commit ddf76d3

File tree

13 files changed

+185
-7
lines changed

13 files changed

+185
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<element name="categoryPageProductImage" type="text" selector=".products-grid img[src*='/{{var1}}']" parameterized="true"/>
2424
<element name="categoryPageProductName" type="text" selector=".products.list.items.product-items li:nth-of-type({{line}}) .product-item-link" timeout="30" parameterized="true"/>
2525
<element name="categoryEmptyMessage" type="text" selector=".column.main .message.info.empty"/>
26+
<element name="productName" type="text" selector=".product-item-name"/>
2627
</section>
2728
</sections>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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="AdminAssertQueryLengthHintsActionGroup">
12+
<amOnPage url="{{AdminCatalogSearchConfigurationPage.url}}" stepKey="navigateToConfigurationPage"/>
13+
<scrollTo selector="{{AdminCatalogSearchConfigurationSection.catalogSearchTab}}" stepKey="scrollToCatalogSearchTab"/>
14+
<conditionalClick selector="{{AdminCatalogSearchConfigurationSection.catalogSearchTab}}" dependentSelector="{{AdminCatalogSearchConfigurationSection.minQueryLength}}" visible="false" stepKey="expandCatalogSearchTab"/>
15+
<waitForElementVisible selector="{{AdminCatalogSearchConfigurationSection.minQueryLength}}" stepKey="waitForMinQueryLengthField"/>
16+
<see userInput="{{MinMaxQueryLength.Hint}}" selector="{{AdminCatalogSearchConfigurationSection.minQueryLengthHint}}" stepKey="seeMinQueryLengthHint"/>
17+
<see userInput="{{MinMaxQueryLength.Hint}}" selector="{{AdminCatalogSearchConfigurationSection.maxQueryLengthHint}}" stepKey="seeMaxQueryLengthHint"/>
18+
</actionGroup>
19+
</actionGroups>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="StorefrontSearchProductActionGroup">
12+
<arguments>
13+
<argument name="product"/>
14+
<argument name="textForSearch" type="string"/>
15+
</arguments>
16+
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
17+
<fillField selector="{{StorefrontQuickSearchSection.searchPhrase}}" userInput="{{textForSearch}}" stepKey="fillSearchField"/>
18+
<click selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="clickSearchButton"/>
19+
<see selector="{{StorefrontCategoryMainSection.productName}}" userInput="{{product.name}}" stepKey="seeProductNameInCatalogSearchPage"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="SetMinQueryLengthToDefault" type="catalog_search_config_def">
12+
<requiredEntity type="length_config">DefaultMinQueryLength</requiredEntity>
13+
</entity>
14+
<entity name="SetMinQueryLength" type="catalog_search_config_def">
15+
<requiredEntity type="length_config">SetMinQueryLengthToOne</requiredEntity>
16+
</entity>
17+
<entity name="SetMinQueryLength2" type="catalog_search_config_def">
18+
<requiredEntity type="length_config">SetMinQueryLengthToTwo</requiredEntity>
19+
</entity>
20+
21+
<entity name="SetMinQueryLengthToOne" type="length_config">
22+
<data key="value">1</data>
23+
<data key="inherit">false</data>
24+
</entity>
25+
<entity name="SetMinQueryLengthToTwo" type="length_config">
26+
<data key="value">2</data>
27+
<data key="inherit">false</data>
28+
</entity>
29+
<entity name="DefaultMinQueryLength" type="length_config">
30+
<data key="inherit">true</data>
31+
</entity>
32+
33+
<entity name="MinMaxQueryLength" type="constant">
34+
<data key="Hint">This value must be compatible with the corresponding setting in the configured search engine</data>
35+
</entity>
36+
</entities>
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+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
10+
<operation name="CatalogSearchConfigDefault" dataType="catalog_search_config_def" type="create" auth="adminFormKey" url="/admin/system_config/save/section/catalog/" method="POST" successRegex="/messages-message-success/">
11+
<object key="groups" dataType="catalog_search_config_def">
12+
<object key="search" dataType="catalog_search_config_def">
13+
<object key="fields" dataType="catalog_search_config_def">
14+
<object key="min_query_length" dataType="length_config">
15+
<field key="inherit">boolean</field>
16+
<field key="value">integer</field>
17+
</object>
18+
</object>
19+
</object>
20+
</object>
21+
</operation>
22+
</operations>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCatalogSearchConfigurationSection">
12+
<element name="catalogSearchTab" type="button" selector="#catalog_search-head" timeout="10"/>
13+
<element name="minQueryLength" type="input" selector="#catalog_search_min_query_length"/>
14+
<element name="minQueryLengthInherit" type="checkbox" selector="#catalog_search_min_query_length_inherit"/>
15+
<element name="minQueryLengthHint" type="text" selector="#row_catalog_search_min_query_length .value span"/>
16+
<element name="maxQueryLengthHint" type="text" selector="#row_catalog_search_max_query_length .value span"/>
17+
</section>
18+
</sections>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="StorefrontMinimalQueryLengthForCatalogSearchTest">
12+
<annotations>
13+
<features value="CatalogSearch"/>
14+
<title value="Minimal query length for catalog search"/>
15+
<description value="Minimal query length for catalog search"/>
16+
<stories value="Catalog search"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-15905"/>
19+
<useCaseId value="MAGETWO-73989"/>
20+
<group value="CatalogSearch"/>
21+
</annotations>
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="SetMinQueryLength" stepKey="setMinQueryLength"/>
28+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
29+
</before>
30+
<after>
31+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
32+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
33+
<createData entity="SetMinQueryLengthToDefault" stepKey="setMinimumQueryLengthToDefault"/>
34+
<actionGroup ref="logout" stepKey="logout"/>
35+
</after>
36+
<actionGroup ref="AdminAssertQueryLengthHintsActionGroup" stepKey="assertQueryLengthHints"/>
37+
<actionGroup ref="StorefrontSearchProductActionGroup" stepKey="searchForProducts">
38+
<argument name="product" value="$$createProduct$$"/>
39+
<argument name="textForSearch" value="s"/>
40+
</actionGroup>
41+
<createData entity="SetMinQueryLength2" stepKey="setMinQueryLengthToTwo"/>
42+
<actionGroup ref="StorefrontSearchProductActionGroup" stepKey="searchForProductsAgain">
43+
<argument name="product" value="$$createProduct$$"/>
44+
<argument name="textForSearch" value="si"/>
45+
</actionGroup>
46+
</test>
47+
</tests>

app/code/Magento/CatalogSearch/etc/adminhtml/system.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
<field id="engine" canRestore="1">
2020
<backend_model>Magento\CatalogSearch\Model\Adminhtml\System\Config\Backend\Engine</backend_model>
2121
</field>
22-
<field id="min_query_length" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
22+
<field id="min_query_length" translate="label comment" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
2323
<label>Minimal Query Length</label>
2424
<validate>validate-digits</validate>
25+
<comment>This value must be compatible with the corresponding setting in the configured search engine. Be aware: a low query length limit may cause the performance impact.</comment>
2526
</field>
26-
<field id="max_query_length" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
27+
<field id="max_query_length" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
2728
<label>Maximum Query Length</label>
2829
<validate>validate-digits</validate>
30+
<comment>This value must be compatible with the corresponding setting in the configured search engine.</comment>
2931
</field>
3032
<field id="max_count_cacheable_search_terms" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3133
<label>Number of top search results to cache</label>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</seo>
1414
<search>
1515
<engine>mysql</engine>
16-
<min_query_length>1</min_query_length>
16+
<min_query_length>3</min_query_length>
1717
<max_query_length>128</max_query_length>
1818
<max_count_cacheable_search_terms>100</max_count_cacheable_search_terms>
1919
<enable_eav_indexer>1</enable_eav_indexer>

app/code/Magento/CatalogSearch/i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ name,name
3838
"Maximum Query Length","Maximum Query Length"
3939
"Rebuild Catalog product fulltext search index","Rebuild Catalog product fulltext search index"
4040
"Please enter a valid price range.","Please enter a valid price range."
41+
"This value must be compatible with the corresponding setting in the configured search engine. Be aware: a low query length limit may cause the performance impact.","This value must be compatible with the corresponding setting in the configured search engine. Be aware: a low query length limit may cause the performance impact."
42+
"This value must be compatible with the corresponding setting in the configured search engine.","This value must be compatible with the corresponding setting in the configured search engine."

0 commit comments

Comments
 (0)