13
13
use Magento \CatalogGraphQl \DataProvider \Product \SearchCriteriaBuilder ;
14
14
use Magento \CatalogGraphQl \Model \Resolver \Products \DataProvider \ProductSearch ;
15
15
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
16
+ use Magento \Framework \App \ObjectManager ;
16
17
use Magento \Framework \Api \Search \SearchCriteriaInterface ;
17
18
use Magento \Framework \Api \Search \SearchResultInterface ;
18
19
use Magento \CatalogGraphQl \Model \Resolver \Products \SearchResult ;
@@ -93,6 +94,11 @@ class Search extends CoreSearch
93
94
*/
94
95
protected CategoryCollectionFactory $ categoryCollectionFactory ;
95
96
97
+ /**
98
+ * @var ArgumentsProcessorInterface
99
+ */
100
+ protected ArgumentsProcessorInterface $ argsSelection ;
101
+
96
102
/**
97
103
* @param SearchInterface $search
98
104
* @param SearchResultFactory $searchResultFactory
@@ -106,6 +112,7 @@ class Search extends CoreSearch
106
112
* @param QueryFactory $queryFactory
107
113
* @param StoreManagerInterface $storeManager
108
114
* @param CategoryCollectionFactory $categoryCollectionFactory
115
+ * @param ArgumentsProcessorInterface $argsSelection
109
116
*/
110
117
public function __construct (
111
118
SearchInterface $ search ,
@@ -119,15 +126,17 @@ public function __construct(
119
126
DataPostProcessor $ productPostProcessor ,
120
127
QueryFactory $ queryFactory ,
121
128
StoreManagerInterface $ storeManager ,
122
- CategoryCollectionFactory $ categoryCollectionFactory
129
+ CategoryCollectionFactory $ categoryCollectionFactory ,
130
+ ArgumentsProcessorInterface $ argsSelection
123
131
) {
124
132
parent ::__construct (
125
133
$ search ,
126
134
$ searchResultFactory ,
127
135
$ pageSize ,
128
136
$ fieldSelection ,
129
137
$ productsProvider ,
130
- $ searchCriteriaBuilder
138
+ $ searchCriteriaBuilder ,
139
+ $ argsSelection
131
140
);
132
141
133
142
$ this ->search = $ search ;
@@ -142,6 +151,8 @@ public function __construct(
142
151
$ this ->productSearchResultsInterfaceFactory = $ productSearchResultsInterfaceFactory ;
143
152
$ this ->emulateSearchResult = $ emulateSearchResult ;
144
153
$ this ->categoryCollectionFactory = $ categoryCollectionFactory ;
154
+ $ this ->argsSelection = $ argsSelection ?: ObjectManager::getInstance ()
155
+ ->get (ArgumentsProcessorInterface::class);
145
156
}
146
157
147
158
/**
@@ -261,7 +272,10 @@ private function getSearchResults(SearchCriteriaInterface $searchCriteria, Resol
261
272
*/
262
273
private function buildSearchCriteria (array $ args , ResolveInfo $ info ): SearchCriteriaInterface
263
274
{
264
- $ searchCriteria = $ this ->searchCriteriaBuilder ->build ($ args , $ this ->includeAggregations ($ info ));
275
+ $ productFields = (array )$ info ->getFieldSelection (1 );
276
+ $ fieldName = $ info ->fieldName ?? "" ;
277
+ $ processedArgs = $ this ->argsSelection ->process ((string ) $ fieldName , $ args );
278
+ $ searchCriteria = $ this ->searchCriteriaBuilder ->build ($ processedArgs , $ this ->getIsIncludeAggregations ($ info ));
265
279
266
280
return $ searchCriteria ;
267
281
}
@@ -270,7 +284,7 @@ private function buildSearchCriteria(array $args, ResolveInfo $info): SearchCrit
270
284
* @param ResolveInfo $info
271
285
* @return bool
272
286
*/
273
- private function includeAggregations (ResolveInfo $ info ): bool
287
+ private function getIsIncludeAggregations (ResolveInfo $ info ): bool
274
288
{
275
289
$ productFields = (array )$ info ->getFieldSelection (1 );
276
290
0 commit comments