Skip to content

Commit

Permalink
Merge pull request #1061 from afoucret/fix-search-api-default-store
Browse files Browse the repository at this point in the history
Fix detection of the default store id in search API.
  • Loading branch information
afoucret authored Sep 5, 2018
2 parents ec44c02 + 0150e85 commit 7392ae2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/module-elasticsuite-core/Model/Search/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public function __construct(
*/
public function getRequest(\Magento\Framework\Api\Search\SearchCriteriaInterface $searchCriteria)
{
$storeId = $this->storeManager->getStore()->getId();
$storeId = $this->getCurrentStoreId();

$containerName = $searchCriteria->getRequestName();

$containerConfiguration = $this->getSearchContainerConfiguration($storeId, $containerName);
Expand All @@ -96,6 +97,22 @@ public function getRequest(\Magento\Framework\Api\Search\SearchCriteriaInterface
return $this->searchRequestBuilder->create($storeId, $containerName, $from, $size, $queryText, $sortOrders, $filters, [], $facets);
}

/**
* Return current store id.
*
* @return integer
*/
private function getCurrentStoreId()
{
$storeId = $this->storeManager->getStore()->getId();

if ($storeId == 0) {
$storeId = $this->storeManager->getDefaultStoreView()->getId();
}

return $storeId;
}

/**
* Extract fulltext search query from search criteria.
*
Expand Down

0 comments on commit 7392ae2

Please sign in to comment.