Пример #1
0
 public function reindexProducts()
 {
     $products = $this->productRepository->findAll();
     $this->searchIndexManager->eraseIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME);
     foreach ($products as $product) {
         $this->addProduct($product);
     }
     $index = $this->searchIndexManager->getIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME);
     $index->optimize();
 }
 /**
  * @param SimpleQuery $simpleQuery
  *
  * @return $this
  */
 public function searchProducts(SimpleQuery $simpleQuery)
 {
     $index = $this->searchIndexManager->getIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME);
     $results = $index->find($simpleQuery->getSearchPhrase() . '~');
     foreach ($results as $result) {
         if ($result->score >= 0.1) {
             $this->currentIdentifiers[] = $result->identifier;
         }
     }
     return $this;
 }