public function testResetSearchResult() { $this->resource->expects($this->once())->method('getTableName')->with('search_query', ResourceConnection::DEFAULT_CONNECTION)->willReturn('table_name_search_query'); $this->connection->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10); $result = $this->target->resetSearchResults(); $this->assertEquals($this->target, $result); }
/** * Execute full indexation * * @return void */ public function executeFull() { $storeIds = array_keys($this->storeManager->getStores()); /** @var IndexerHandler $saveHandler */ $saveHandler = $this->indexerHandlerFactory->create(['data' => $this->data]); foreach ($storeIds as $storeId) { $dimension = $this->dimensionFactory->create(['name' => 'scope', 'value' => $storeId]); $saveHandler->cleanIndex([$dimension]); $saveHandler->saveIndex([$dimension], $this->fullAction->rebuildStoreIndex($storeId)); } $this->fulltextResource->resetSearchResults(); $this->searchRequestConfig->reset(); }
/** * Search the text and return result collection * * @param string $text * @return Product[] */ protected function search($text) { $this->resourceFulltext->resetSearchResults(); $query = $this->queryFactory->get(); $query->unsetData(); $query->setQueryText($text); $query->saveIncrementalPopularity(); $products = []; $collection = Bootstrap::getObjectManager()->create(Collection::class, ['searchRequestName' => 'quick_search_container']); $collection->addSearchFilter($text); foreach ($collection as $product) { $products[] = $product; } return $products; }
/** * Regenerate search index for all stores * * @param int|array|null $productIds * @return void */ protected function rebuildIndex($productIds = null) { $storeIds = array_keys($this->storeManager->getStores()); foreach ($storeIds as $storeId) { $dimension = $this->dimensionFactory->create(['name' => self::SCOPE_FIELD_NAME, 'value' => $storeId]); $this->indexHandler->deleteIndex([$dimension], $this->getIterator($productIds)); $this->indexHandler->saveIndex([$dimension], $this->rebuildStoreIndex($storeId, $productIds)); } $this->fulltextResource->resetSearchResults(); $this->searchRequestConfig->reset(); }