Skip to content

Commit 01e03bd

Browse files
committed
ACP2E-3897: [Mainline] Wrong results in products graphQL query
1 parent f70c057 commit 01e03bd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SearchCriteriaBuilder
3838
* @param RequestDataBuilder $localData
3939
* @param SearchCriteriaResolverFactory $criteriaResolverFactory
4040
* @param ArgumentApplierPool $argumentApplierPool
41+
* @param array $partial_search_analyzers
4142
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4243
*/
4344
public function __construct(
@@ -51,6 +52,7 @@ public function __construct(
5152
private readonly RequestDataBuilder $localData,
5253
private readonly SearchCriteriaResolverFactory $criteriaResolverFactory,
5354
private readonly ArgumentApplierPool $argumentApplierPool,
55+
private readonly array $partial_search_analyzers = []
5456
) {
5557
}
5658

@@ -117,8 +119,8 @@ private function updateMatchTypeRequestConfig(string $requestName, array $partia
117119
foreach ($query['match'] ?? [] as $index => $matchItem) {
118120
if (in_array($matchItem['field'] ?? null, $partialMatchFilters, true)) {
119121
$data['queries'][$queryName]['match'][$index]['matchCondition'] = 'match_phrase_prefix';
120-
if ($matchItem['field'] === 'name') {
121-
$data['queries'][$queryName]['match'][$index]['analyzer'] = 'prefix_search';
122+
if (array_key_exists($matchItem['field'], $this->partial_search_analyzers)) {
123+
$data['queries'][$queryName]['match'][$index]['analyzer'] = $this->partial_search_analyzers[$matchItem['field']];
122124
}
123125
}
124126
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,12 @@
150150
</argument>
151151
</arguments>
152152
</type>
153+
154+
<type name="Magento\CatalogGraphQl\DataProvider\Product\SearchCriteriaBuilder">
155+
<arguments>
156+
<argument name="partial_search_analyzers" xsi:type="array">
157+
<item name="name" xsi:type="string">prefix_search</item>
158+
</argument>
159+
</arguments>
160+
</type>
153161
</config>

0 commit comments

Comments
 (0)