Smile\ElasticsuiteCore\Helper\IndexSettings::createIndexNameFromIdentifier PHP Метод

createIndexNameFromIdentifier() публичный Метод

Create a new index for an identifier (eg. catalog_product) by store including current date.
public createIndexNameFromIdentifier ( string $indexIdentifier, integer | string | Magento\Store\Api\Data\StoreInterface $store ) : string
$indexIdentifier string Index identifier.
$store integer | string | Magento\Store\Api\Data\StoreInterface The store.
Результат string
    public function createIndexNameFromIdentifier($indexIdentifier, $store)
    {
        /*
         * Generate the suffix of the index name from the current date.
         * e.g : Default pattern "{{YYYYMMdd}}_{{HHmmss}}" is converted to "20160221-123421".
         */
        $indiceNameSuffix = $this->getIndicesSettingsConfigParam('indices_pattern');
        $currentDate = new \Zend_Date();
        // Parse pattern to extract datetime tokens.
        $matches = [];
        preg_match_all('/{{([\\w]*)}}/', $indiceNameSuffix, $matches);
        foreach (array_combine($matches[0], $matches[1]) as $k => $v) {
            // Replace tokens (UTC date used).
            $indiceNameSuffix = str_replace($k, $currentDate->toString($v), $indiceNameSuffix);
        }
        return sprintf('%s_%s', $this->getIndexAliasFromIdentifier($indexIdentifier, $store), $indiceNameSuffix);
    }

Usage Example

Пример #1
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);
 }
All Usage Examples Of Smile\ElasticsuiteCore\Helper\IndexSettings::createIndexNameFromIdentifier