Author: Aurelien FOUCRET (aurelien.foucret@smile.fr)
Inheritance: extends Magento\Framework\App\Helper\AbstractHelper
Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function getSpellingType(RequestInterface $request)
 {
     $cacheKey = $this->getCacheKey($request);
     $spellingType = $this->cacheHelper->loadCache($cacheKey);
     if ($spellingType === false) {
         $spellingType = $this->loadSpellingType($request);
         $this->cacheHelper->saveCache($cacheKey, $spellingType, [$request->getIndex()]);
     }
     return $spellingType;
 }
Esempio n. 2
0
 /**
  * Create the synonyms index for a store id.
  *
  * @param integer  $storeId    Store id.
  * @param string[] $synonyms   Raw synonyms list.
  * @param string[] $expansions Raw expansions list.
  *
  * @return void
  */
 public function reindex($storeId, $synonyms, $expansions)
 {
     $indexIdentifier = ThesaurusIndex::INDEX_IDENTIER;
     $indexName = $this->indexSettingsHelper->createIndexNameFromIdentifier($indexIdentifier, $storeId);
     $indexAlias = $this->indexSettingsHelper->getIndexAliasFromIdentifier($indexIdentifier, $storeId);
     $indexSettings = ['settings' => $this->getIndexSettings($synonyms, $expansions)];
     $this->client->indices()->create(['index' => $indexName, 'body' => $indexSettings]);
     $this->indexManager->proceedIndexInstall($indexName, $indexAlias);
     $this->cacheHelper->cleanIndexCache(ThesaurusIndex::INDEX_IDENTIER, $storeId);
 }
Esempio n. 3
0
 /**
  * Provides weigthed rewrites for the query.
  *
  * @param ContainerConfigurationInterface $containerConfig Search request container config.
  * @param string                          $queryText       Fulltext query.
  *
  * @return array
  */
 public function getQueryRewrites(ContainerConfigurationInterface $containerConfig, $queryText)
 {
     $cacheKey = $this->getCacheKey($containerConfig, $queryText);
     $cacheTags = $this->getCacheTags($containerConfig);
     $queryRewrites = $this->cacheHelper->loadCache($cacheKey);
     if ($queryRewrites === false) {
         $queryRewrites = $this->computeQueryRewrites($containerConfig, $queryText);
         $this->cacheHelper->saveCache($cacheKey, $queryRewrites, $cacheTags);
     }
     return $queryRewrites;
 }
 /**
  * {@inheritDoc}
  */
 public function saveIndex($dimensions, \Traversable $documents)
 {
     foreach ($dimensions as $dimension) {
         $storeId = $dimension->getValue();
         $index = $this->indexOperation->getIndexByName($this->indexName, $storeId);
         $type = $index->getType($this->typeName);
         foreach ($this->batch->getItems($documents, $this->batchSize) as $batchDocuments) {
             foreach ($type->getDatasources() as $datasource) {
                 $batchDocuments = $datasource->addData($storeId, $batchDocuments);
             }
             $bulk = $this->indexOperation->createBulk()->addDocuments($index, $type, $batchDocuments);
             $this->indexOperation->executeBulk($bulk);
         }
         $this->indexOperation->refreshIndex($index);
         $this->indexOperation->installIndex($index, $storeId);
         $this->cacheHelper->cleanIndexCache($this->indexName, $storeId);
     }
     return $this;
 }