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
211211 $ searchCriteria = $ this ->searchResult ->getSearchCriteria ();
212212 $ sortOrders = $ searchCriteria ->getSortOrders () ?? [];
213213 $ sortOrders = array_merge (['is_salable ' => \Magento \Framework \DB \Select::SQL_DESC ], $ sortOrders );
214-
215214 $ connection = $ this ->collection ->getConnection ();
216215 $ query = clone $ connection ->select ()
217216 ->reset (\Magento \Framework \DB \Select::ORDER )
@@ -231,6 +230,14 @@ private function categoryProductByCustomSortOrder(int $categoryId): array
231230 . ' AND cat_index.store_id = ' . $ storeId ,
232231 ['cat_index.position ' ]
233232 );
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+
234241 foreach ($ sortOrders as $ field => $ dir ) {
235242 if ($ field === 'name ' ) {
236243 $ entityTypeId = $ this ->collection ->getEntity ()->getTypeId ();
You can’t perform that action at this time.
0 commit comments