Skip to content

Commit 30c0da3

Browse files
authored
Merge pull request #14 from landofcoder/fix-graphql-issue
Fix graphql issue
2 parents 0cb156e + 40a516e commit 30c0da3

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

Model/Resolver/Products/DataProvider/ProductSearch.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,29 @@ 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+
}
147+
148+
$collection->setFlag('search_resut_applied', true);
131149

132150
$this->collectionPreProcessor->process($collection, $searchCriteriaForCollection, $attributes, $context);
133151
$collection->load();
@@ -185,7 +203,6 @@ private function getSortOrderArray(SearchCriteriaInterface $searchCriteria)
185203
$ordersArray[$sortOrder->getField()] = $sortOrder->getDirection();
186204
}
187205
}
188-
189206
return $ordersArray;
190207
}
191208
}

Model/Resolver/Products/DataProvider/Sellers.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ public function getListSellers
166166
) . $data["thumbnail"];
167167
}
168168
$args['seller_id'] = $val->getData('seller_id');
169-
$sellerRates = $this->sellerFrontendRepository->getSellersRating($data['seller_id']);
170-
$data['seller_rates'] = $sellerRates;
169+
$sellerRates = $this->sellerFrontendRepository->getSellersRating((int)$data['seller_id']);
170+
$data['seller_rates'] = [
171+
'total_count' => $sellerRates->getTotalCount(),
172+
'items' => $sellerRates->getItems()
173+
];
171174
$data['group_id'] = $val->getGroupId();
172175
$data['group'] = $val->getSellerGroup();
176+
$data['country'] = !empty($val->getCountry()) ? $val->getCountry() : $val->getCountryId();
173177
$data['products'] = $this->getResult( $args, $info, $context);
174178
$items[] = $data;
175179
}

Model/Resolver/Sellers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Sellers extends AbstractSellerQuery implements ResolverInterface
4545
{
4646

4747
/**
48-
* @var SellersFrontendRepositoryInterface
48+
* @var Products\Query\SellerQueryInterface
4949
*/
5050
private $sellers;
5151

0 commit comments

Comments
 (0)