_storeManager = $storeManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); } /** * Define resource model * * @return void */ protected function _construct() { $this->_init( \Olegnax\Athlete2Slideshow\Model\Slides::class, Slides::class ); } /** * Set store scope * * @param int|string|StoreInterface $storeId * * @return $this */ public function setStoreId($storeId) { if ($storeId instanceof StoreInterface) { $storeId = $storeId->getId(); } $this->_storeId = (int) $storeId; return $this; } /** * Return current store id * * @return int */ public function getStoreId() { if ($this->_storeId === null) { $this->setStoreId($this->_storeManager->getStore()->getId()); } return $this->_storeId; } /** * Add store availability filter. Include availability product * for store website * * @param null|string|bool|int $store * @return $this */ public function addStoreFilter($store = null) { if ($store === null) { $store = $this->getStoreId(); } $store = $this->_storeManager->getStore($store); $this->getSelect()->where("(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int'); return $this; } }