_eventManager = $eventManager; $this->metadataPool = $metadataPool ? : ObjectManager::getInstance()->get(MetadataPool::class); parent::__construct($context, $connectionName); } /** * Init resource model * * @return void */ protected function _construct() { $this->_init('catalogsearch_fulltext', 'product_id'); } /** * Reset search results * * @return $this * @deprecated 101.0.0 Not used anymore * @see Fulltext::resetSearchResultsByStore */ public function resetSearchResults() { $connection = $this->getConnection(); $connection->update($this->getTable('search_query'), ['is_processed' => 0], ['is_processed != 0']); $this->_eventManager->dispatch('catalogsearch_reset_search_result'); return $this; } /** * Reset search results by store * * @param int $storeId * @return $this * @since 101.0.0 */ public function resetSearchResultsByStore($storeId) { $storeId = (int) $storeId; $connection = $this->getConnection(); $connection->update( $this->getTable('search_query'), ['is_processed' => 0], ['is_processed != ?' => 0, 'store_id = ?' => $storeId] ); $this->_eventManager->dispatch('catalogsearch_reset_search_result', ['store_id' => $storeId]); return $this; } /** * Retrieve product relations by children. * * @param int|array $childIds * @return array * @since 100.2.0 */ public function getRelationsByChild($childIds) { $connection = $this->getConnection(); $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); $select = $connection ->select() ->from( ['relation' => $this->getTable('catalog_product_relation')], [] )->distinct(true) ->join( ['cpe' => $this->getTable('catalog_product_entity')], 'cpe.' . $linkField . ' = relation.parent_id', ['cpe.entity_id'] )->where( 'relation.child_id IN (?)', $childIds ); return $connection->fetchCol($select); } }