/** * Filter the select to append only product visible into the catalog or search into the index. * * Note : Magento put only enabled products that have the following * visibility into the catalog_category_product_index table : * - visible in catalog * - visible in search * - visible in catalog & search * * So joining on the root category will filter only products that have to be indexed * and you don't need to put any additional filter on the visibility field. * * @param \Zend_Db_Select $select Product select to be filtered. * @param integer $storeId Store Id * * @return \Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Indexer\Fulltext\Action\Full Self Reference */ private function addIsVisibleInStoreFilter($select, $storeId) { $rootCategoryId = $this->getRootCategoryId($storeId); $indexTable = $this->getTable('catalog_category_product_index'); $visibilityJoinCond = $this->getConnection()->quoteInto('visibility.product_id = e.entity_id AND visibility.store_id = ?', $storeId); $select->useStraightJoin(true)->join(['visibility' => $indexTable], $visibilityJoinCond, ['visibility'])->where('visibility.category_id = ?', (int) $rootCategoryId); return $this; }