Skip to content

Commit 482d2be

Browse files
committed
ACP2E-3897: [Mainline] Wrong results in products graphQL query
1 parent 9139230 commit 482d2be

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SearchCriteriaBuilder
3838
* @param RequestDataBuilder $localData
3939
* @param SearchCriteriaResolverFactory $criteriaResolverFactory
4040
* @param ArgumentApplierPool $argumentApplierPool
41-
* @param array $partial_search_analyzers
41+
* @param array $partialSearchAnalyzers
4242
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4343
*/
4444
public function __construct(
@@ -52,7 +52,7 @@ public function __construct(
5252
private readonly RequestDataBuilder $localData,
5353
private readonly SearchCriteriaResolverFactory $criteriaResolverFactory,
5454
private readonly ArgumentApplierPool $argumentApplierPool,
55-
private readonly array $partial_search_analyzers = []
55+
private readonly array $partialSearchAnalyzers = []
5656
) {
5757
}
5858

@@ -119,9 +119,9 @@ private function updateMatchTypeRequestConfig(string $requestName, array $partia
119119
foreach ($query['match'] ?? [] as $index => $matchItem) {
120120
if (in_array($matchItem['field'] ?? null, $partialMatchFilters, true)) {
121121
$data['queries'][$queryName]['match'][$index]['matchCondition'] = 'match_phrase_prefix';
122-
if (array_key_exists($matchItem['field'], $this->partial_search_analyzers)) {
122+
if (array_key_exists($matchItem['field'], $this->partialSearchAnalyzers)) {
123123
$data['queries'][$queryName]['match'][$index]['analyzer']
124-
= $this->partial_search_analyzers[$matchItem['field']];
124+
= $this->partialSearchAnalyzers[$matchItem['field']];
125125
}
126126
}
127127
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,34 +205,26 @@ public function sortByPriceAndNameDataProvider(): array
205205
}
206206

207207
/**
208-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
209208
* @dataProvider filterByNameWithMatchTypeSpecifiedDataProvider
210209
*/
211210
#[
212211
DataFixture(ProductFixture::class, ['price' => 10, 'name' => 'Cronus Yoga Pant'], 'prod1'),
213212
DataFixture(ProductFixture::class, ['price' => 10, 'name' => 'Lucia Cross-Fit Bra'], 'prod2'),
214213
DataFixture(ProductFixture::class, ['price' => 20, 'name' => 'Crown Summit Backpack'], 'prod3'),
215214
]
216-
public function testFilterByNameWithMatchTypeSpecified($matchType, $expectedOrder, $expectedTotalCount): void
215+
public function testFilterByNameWithMatchTypeSpecified($matchType, $expectedReturns, $expectedTotalCount): void
217216
{
218217
$expectedNames = [];
219-
foreach ($expectedOrder as $productName) {
218+
foreach ($expectedReturns as $productName) {
220219
$expectedNames[] = $this->fixture->get($productName)->getName();
221220
}
222221
$query = <<<'QUERY'
223222
query GetProductsQuery(
224-
$search: String,
225223
$searchWord: String,
226224
$matchType: FilterMatchTypeEnum
227-
$pageSize: Int,
228-
$currentPage: Int
229225
) {
230226
products(
231-
search: $search,
232227
filter: {name: {match: $searchWord, match_type: $matchType} },
233-
pageSize: $pageSize,
234-
currentPage: $currentPage,
235-
sort: {name: ASC}
236228
) {
237229
total_count
238230
page_info{total_pages}
@@ -246,11 +238,8 @@ public function testFilterByNameWithMatchTypeSpecified($matchType, $expectedOrde
246238
}
247239
QUERY;
248240
$variables = [
249-
'search' => null,
250241
'searchWord' => 'Cros',
251242
'matchType' => $matchType,
252-
'pageSize' => 24,
253-
'currentPage' => 1
254243
];
255244

256245
$response = $this->graphQlQuery($query, $variables);

0 commit comments

Comments
 (0)