@@ -99,15 +99,14 @@ public function afterGetFilters(
9999 ) {
100100 $ storeId = $ containerConfiguration ->getStoreId ();
101101 if ($ this ->isEnabled ($ containerConfiguration )) {
102+ $ result = $ this ->decodeCategoryUid ($ result );
102103 if (isset ($ result ['category.category_id ' ]) && !isset ($ result ['category.category_uid ' ])) {
103104 $ result [] = $ this ->getCategoriesQuery ($ result ['category.category_id ' ], $ storeId );
104105
105106 unset($ result ['category.category_id ' ]);
106- } elseif (isset ($ result ['category.category_uid ' ]) && isset ($ result ['category.category_uid ' ]['eq ' ]) &&
107- !isset ($ result ['category.category_id ' ])) {
108- $ categoryUid [] = $ this ->uidEncoder ->decode ($ result ['category.category_uid ' ]['eq ' ]);
107+ } elseif (isset ($ result ['category.category_uid ' ]) && !isset ($ result ['category.category_id ' ])) {
108+ $ result [] = $ this ->getCategoriesQuery ($ result ['category.category_uid ' ], $ storeId );
109109
110- $ result [] = $ this ->getCategoriesQuery ($ categoryUid , $ storeId );
111110 unset($ result ['category.category_uid ' ]);
112111 } elseif (isset ($ result ['category.category_id ' ]) && isset ($ result ['category.category_uid ' ])) {
113112 $ result [] = $ this ->getCategoriesQuery ($ result ['category.category_id ' ], $ storeId );
@@ -181,4 +180,33 @@ private function getCategorySubQuery($categoryId, $storeId)
181180
182181 return $ this ->filterProvider ->getQueryFilter ($ category );
183182 }
183+
184+ /**
185+ * Decode category_uid params if present in the request, because they are base64 encoded.
186+ *
187+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
188+ *
189+ * @param array $result The array containing potentially the params.
190+ *
191+ * @return array
192+ * @throws \Magento\Framework\GraphQl\Exception\GraphQlInputException
193+ */
194+ private function decodeCategoryUid (&$ result )
195+ {
196+ if (isset ($ result ['category.category_uid ' ])) {
197+ $ decodeCb = function (string $ categoryUid ) {
198+ return $ this ->uidEncoder ->decode ($ categoryUid );
199+ };
200+
201+ foreach ($ result ['category.category_uid ' ] as $ operator => &$ categoryIds ) {
202+ if (!is_array ($ categoryIds )) {
203+ $ categoryIds = [$ categoryIds ];
204+ }
205+
206+ $ categoryIds = array_map ($ decodeCb , $ categoryIds );
207+ }
208+ }
209+
210+ return $ result ;
211+ }
184212}
0 commit comments