Skip to content

Commit 41c52f3

Browse files
committed
MAGE-1260: use entity index options builders
1 parent 499999d commit 41c52f3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Service/Product/BackendSearch.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
77
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
88
use Algolia\AlgoliaSearch\Service\AlgoliaConnector;
9-
use Algolia\AlgoliaSearch\Service\IndexOptionsBuilder;
109
use Magento\Framework\Exception\NoSuchEntityException;
1110

1211
class BackendSearch
@@ -30,9 +29,9 @@ public function __construct(
3029
*/
3130
public function getSearchResult(string $query, int $storeId, ?array $searchParams = null, ?string $targetedIndex = null): array
3231
{
33-
$indexName = $targetedIndex !== null ?
34-
$targetedIndex :
35-
$this->productHelper->getIndexName($storeId);
32+
$indexOptions = $targetedIndex !== null ?
33+
$this->indexOptionsBuilder->buildWithEnforcedIndex($targetedIndex, $storeId) :
34+
$this->indexOptionsBuilder->buildEntityIndexOptions($storeId);
3635

3736
$numberOfResults = 1000;
3837
if ($this->configHelper->isInstantEnabled()) {
@@ -60,7 +59,6 @@ public function getSearchResult(string $query, int $storeId, ?array $searchParam
6059
$params = array_merge($params, $searchParams);
6160
}
6261

63-
$indexOptions = $this->indexOptionsBuilder->buildWithEnforcedIndex($indexName, $storeId);
6462
$response = $this->algoliaConnector->query($indexOptions, $query, $params);
6563
$answer = reset($response['results']);
6664

0 commit comments

Comments
 (0)