Skip to content

Commit 40a516e

Browse files
committed
fix elasticsuite issue
1 parent 28a48e1 commit 40a516e

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Model/Resolver/Products/DataProvider/ProductSearch.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,27 @@ public function getList(
123123
//Create a copy of search criteria without filters to preserve the results from search
124124
$searchCriteriaForCollection = $this->searchCriteriaBuilder->build($searchCriteria);
125125
//Apply CatalogSearch results from search and join table
126-
// $this->getSearchResultsApplier(
127-
// $searchResult,
128-
// $collection,
129-
// $this->getSortOrderArray($searchCriteriaForCollection)
130-
// )->apply();
126+
if (!empty($searchResult) && $searchResult->getItems()) {
127+
$items = [];
128+
foreach ($searchResult->getItems() as $_item) {
129+
if (get_class($_item) == "Smile\\ElasticsuiteCore\\Search\\Adapter\\Elasticsuite\\Response\\Document") {
130+
$score = $_item->getCustomAttribute('score');
131+
if (!$score) {
132+
$_item->setCustomAttribute('score', '');
133+
}
134+
$items[] = $_item;
135+
}
136+
}
137+
if (!empty($items)) {
138+
$searchResult->setItems($items);
139+
}
140+
141+
$this->getSearchResultsApplier(
142+
$searchResult,
143+
$collection,
144+
$this->getSortOrderArray($searchCriteriaForCollection)
145+
)->apply();
146+
}
131147

132148
$collection->setFlag('search_resut_applied', true);
133149

0 commit comments

Comments
 (0)