Skip to content

Commit 7792c18

Browse files
committed
Merge remote-tracking branch 'Bashev/Issue-35899' into AC-6395
2 parents f26ae80 + a32e734 commit 7792c18

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)