Skip to content

Commit e53b688

Browse files
committed
ACP2E-1870: Advanced search price filter is not working along with SKU
1 parent 3d49b24 commit e53b688

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<queries>
6868
<query xsi:type="boolQuery" name="advanced_search_container" boost="1">
6969
<queryReference clause="should" ref="sku_query"/>
70-
<queryReference clause="should" ref="price_query"/>
70+
<queryReference clause="must" ref="price_query"/>
7171
<queryReference clause="should" ref="category_query"/>
7272
<queryReference clause="must" ref="visibility_query"/>
7373
</query>

dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/Advanced/ResultTest.php

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,42 @@ public function testExecuteWithArrayInParam(array $searchParams): void
165165
);
166166
}
167167

168+
/**
169+
* Advanced search test by difference product attributes.
170+
*
171+
* @magentoAppArea frontend
172+
* @magentoDataFixture Magento/CatalogSearch/_files/product_for_search.php
173+
* @magentoDataFixture Magento/CatalogSearch/_files/full_reindex.php
174+
* @dataProvider testDataForAttributesCombination
175+
*
176+
* @param array $searchParams
177+
* @param bool $isProductShown
178+
* @return void
179+
*/
180+
public function testExecuteForAttributesCombination(array $searchParams, bool $isProductShown): void
181+
{
182+
$this->getRequest()->setQuery(
183+
$this->_objectManager->create(
184+
Parameters::class,
185+
[
186+
'values' => $searchParams
187+
]
188+
)
189+
);
190+
$this->dispatch('catalogsearch/advanced/result');
191+
$responseBody = $this->getResponse()->getBody();
192+
193+
if ($isProductShown) {
194+
$this->assertStringContainsString('Simple product name', $responseBody);
195+
} else {
196+
$this->assertStringContainsString(
197+
'We can&#039;t find any items matching these search criteria.',
198+
$responseBody
199+
);
200+
}
201+
$this->assertStringNotContainsString('Not visible simple product', $responseBody);
202+
}
203+
168204
/**
169205
* Data provider with array in params values
170206
*
@@ -339,4 +375,71 @@ private function getAttributeOptionValueByOptionLabel(string $attributeCode, str
339375

340376
return $attribute->getSource()->getOptionId($optionLabel);
341377
}
378+
379+
/**
380+
* Data provider with strings for quick search.
381+
*
382+
* @return array
383+
*/
384+
public function testDataForAttributesCombination(): array
385+
{
386+
return [
387+
'search_product_by_name_and_price' => [
388+
[
389+
'name' => 'Simple product name',
390+
'sku' => '',
391+
'description' => '',
392+
'short_description' => '',
393+
'price' => [
394+
'from' => 99,
395+
'to' => 101,
396+
],
397+
'test_searchable_attribute' => '',
398+
],
399+
true
400+
],
401+
'search_product_by_name_and_price_not_shown' => [
402+
[
403+
'name' => 'Simple product name',
404+
'sku' => '',
405+
'description' => '',
406+
'short_description' => '',
407+
'price' => [
408+
'from' => 101,
409+
'to' => 102,
410+
],
411+
'test_searchable_attribute' => '',
412+
],
413+
false
414+
],
415+
'search_product_by_sku' => [
416+
[
417+
'name' => '',
418+
'sku' => 'simple_for_search',
419+
'description' => '',
420+
'short_description' => '',
421+
'price' => [
422+
'from' => 99,
423+
'to' => 101,
424+
],
425+
'test_searchable_attribute' => '',
426+
],
427+
true
428+
],
429+
'search_product_by_sku_not_shown' => [
430+
[
431+
'name' => '',
432+
'sku' => 'simple_for_search',
433+
'description' => '',
434+
'short_description' => '',
435+
'price' => [
436+
'from' => 990,
437+
'to' => 1010,
438+
],
439+
'test_searchable_attribute' => '',
440+
],
441+
false
442+
],
443+
];
444+
}
342445
}

0 commit comments

Comments
 (0)