diff --git a/Model/ResourceModel/Post/Fulltext/Collection.php b/Model/ResourceModel/Post/Fulltext/Collection.php index 34cf3d5..c6b4c40 100755 --- a/Model/ResourceModel/Post/Fulltext/Collection.php +++ b/Model/ResourceModel/Post/Fulltext/Collection.php @@ -75,8 +75,8 @@ public function __construct( \Smile\ElasticsuiteCore\Search\Request\Builder $requestBuilder, \Magento\Search\Model\SearchEngine $searchEngine, $searchRequestName = 'blog_search_container', - \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null + ?\Magento\Framework\DB\Adapter\AdapterInterface $connection = null, + ?\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $date, $storeManager, $connection, $resource); @@ -123,11 +123,18 @@ public function setStoreId($storeId) /** * Returns current store id. * + * Falls back to the current store when no store filter was set, + * e.g. when the collection is built on the catalogsearch result page. + * * @return int */ - public function getStoreId() + public function getStoreId(): int { - return $this->storeId; + if ($this->storeId === null) { + $this->storeId = (int) $this->_storeManager->getStore()->getId(); + } + + return (int) $this->storeId; } /**