Skip to content

Commit

Permalink
Fix detection of the default store id in search API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurélien FOUCRET committed Sep 5, 2018
1 parent 54f4d4f commit 0150e85
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 0150e85

Please sign in to comment.