File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,6 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
211
211
$ searchCriteria = $ this ->searchResult ->getSearchCriteria ();
212
212
$ sortOrders = $ searchCriteria ->getSortOrders () ?? [];
213
213
$ sortOrders = array_merge (['is_salable ' => \Magento \Framework \DB \Select::SQL_DESC ], $ sortOrders );
214
-
215
214
$ connection = $ this ->collection ->getConnection ();
216
215
$ query = clone $ connection ->select ()
217
216
->reset (\Magento \Framework \DB \Select::ORDER )
@@ -231,6 +230,14 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
231
230
. ' AND cat_index.store_id = ' . $ storeId ,
232
231
['cat_index.position ' ]
233
232
);
233
+
234
+ $ productIds = [];
235
+ foreach ($ this ->searchResult ->getItems () as $ item ) {
236
+ $ productIds [] = $ item ->getId ();
237
+ }
238
+
239
+ $ query ->where ('e.entity_id IN(?) ' , $ productIds );
240
+
234
241
foreach ($ sortOrders as $ field => $ dir ) {
235
242
if ($ field === 'name ' ) {
236
243
$ entityTypeId = $ this ->collection ->getEntity ()->getTypeId ();
You can’t perform that action at this time.
0 commit comments