示例#1
0
文件: Store.php 项目: nja78/magento2
 /**
  * @param \Magento\Store\Model\Store $store
  * @return void
  */
 private function clearIndex(\Magento\Store\Model\Store $store)
 {
     $dimensions = [$this->dimensionFactory->create(['name' => 'scope', 'value' => $store->getId()])];
     $configData = $this->indexerConfig->getIndexer(FulltextIndexer::INDEXER_ID);
     /** @var \Magento\CatalogSearch\Model\Indexer\IndexerHandler $indexHandler */
     $indexHandler = $this->indexerHandlerFactory->create(['data' => $configData]);
     $indexHandler->cleanIndex($dimensions);
 }
示例#2
0
 /**
  * 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();
 }
示例#3
0
 /**
  * Reindex all stores
  *
  * @return bool
  */
 public function reindexAll()
 {
     $configData = ['fieldsets' => [], 'indexer_id' => $this->index->getCode()];
     /** @var \Magento\CatalogSearch\Model\Indexer\IndexerHandler $indexHandler */
     $indexHandler = $this->indexHandlerFactory->create(['data' => $configData]);
     $storeIds = array_keys($this->storeManager->getStores());
     foreach ($storeIds as $storeId) {
         $dimension = new Dimension('scope', $storeId);
         $indexHandler->cleanIndex([$dimension]);
         $indexHandler->saveIndex([$dimension], $this->rebuildStoreIndex($storeId));
     }
     $this->index->getModel()->setStatus(Config::INDEX_STATUS_READY)->save();
     return true;
 }
示例#4
0
文件: Full.php 项目: nja78/magento2
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Catalog\Model\Product\Type $catalogProductType
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param \Magento\Framework\Search\Request\Config $searchRequestConfig
  * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus
  * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory
  * @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider
  * @param \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Stdlib\DateTime $dateTime
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
  * @param \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource
  * @param \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory
  * @param \Magento\Indexer\Model\ConfigInterface $indexerConfig
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Search\Request\Config $searchRequestConfig, \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $productAttributeCollectionFactory, \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider, \Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory $indexHandlerFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource, \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory, \Magento\Indexer\Model\ConfigInterface $indexerConfig)
 {
     $this->resource = $resource;
     $this->catalogProductType = $catalogProductType;
     $this->eavConfig = $eavConfig;
     $this->searchRequestConfig = $searchRequestConfig;
     $this->catalogProductStatus = $catalogProductStatus;
     $this->productAttributeCollectionFactory = $productAttributeCollectionFactory;
     $this->eventManager = $eventManager;
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->engine = $engineProvider->get();
     $configData = $indexerConfig->getIndexer(Fulltext::INDEXER_ID);
     $this->indexHandler = $indexHandlerFactory->create(['data' => $configData]);
     $this->dateTime = $dateTime;
     $this->localeResolver = $localeResolver;
     $this->localeDate = $localeDate;
     $this->fulltextResource = $fulltextResource;
     $this->dimensionFactory = $dimensionFactory;
 }