本文整理汇总了PHP中Magento\Framework\Indexer\IndexerRegistry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP IndexerRegistry::get方法的具体用法?PHP IndexerRegistry::get怎么用?PHP IndexerRegistry::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Indexer\IndexerRegistry
的用法示例。
在下文中一共展示了IndexerRegistry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getVersion(), '2.0.6', '<')) {
$this->upgradeVersionTwoZeroSix($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->upgradeVersionTwoZeroOne($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$this->upgradeVersionTwoZeroTwo($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.3', '<')) {
$this->upgradeVersionTwoZeroThree($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.4', '<')) {
$this->upgradeVersionTwoZeroFour($customerSetup);
}
if (version_compare($context->getVersion(), '2.0.5', '<')) {
$this->upgradeVersionTwoZeroFive($customerSetup, $setup);
}
if (version_compare($context->getVersion(), '2.0.6', '<')) {
$setup->getConnection()->delete($setup->getTable('customer_form_attribute'), ['form_code = ?' => 'checkout_register']);
}
if (version_compare($context->getVersion(), '2.0.7', '<')) {
$this->upgradeVersionTwoZeroSeven($customerSetup);
$this->upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup);
}
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
示例2: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$indexer = $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID);
$indexer->reindexAll();
$setup->endSetup();
}
示例3: reindexList
/**
* Reindex by product if indexer is not scheduled
*
* @param int[] $productIds
* @return void
*/
protected function reindexList(array $productIds)
{
$indexer = $this->indexerRegistry->get(Fulltext::INDEXER_ID);
if (!$indexer->isScheduled()) {
$indexer->reindexList($productIds);
}
}
示例4: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$entityAttributes = ['customer' => ['website_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_in' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'email' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'group_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'dob' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'taxvat' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'confirmation' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_at' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'gender' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false]], 'customer_address' => ['company' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'street' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'city' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'country_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'region' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'region_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'postcode' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'telephone' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'fax' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
$attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
$option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
$customerSetup->addAttributeOption($option);
}
if (version_compare($context->getVersion(), '2.0.3', '<')) {
$entityAttributes = ['customer_address' => ['region_id' => ['is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => false], 'firstname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'lastname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
if (version_compare($context->getVersion(), '2.0.4', '<')) {
$customerSetup->addAttribute(Customer::ENTITY, 'updated_at', ['type' => 'static', 'label' => 'Updated At', 'input' => 'date', 'required' => false, 'sort_order' => 87, 'visible' => false, 'system' => false]);
}
if (version_compare($context->getVersion(), '2.0.5', '<')) {
$this->upgradeHash($setup);
$entityAttributes = ['customer_address' => ['fax' => ['is_visible' => false, 'is_system' => false]]];
$this->upgradeAttributes($entityAttributes, $customerSetup);
}
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
示例5: afterSave
/**
* After save call
* Invalidate catalog search index if engine was changed
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();
if ($this->isValueChanged()) {
$this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)->invalidate();
}
return $this;
}
示例6: syncCustomerGrid
/**
* Synchronize customer grid
*
* @return void
*/
public function syncCustomerGrid()
{
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$customerIds = $this->getCustomerIdsForReindex();
if ($customerIds) {
$indexer->reindexList($customerIds);
}
}
示例7: aroundSave
/**
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $subject
* @param callable $proceed
* @param \Magento\Framework\Model\AbstractModel $group
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Framework\Model\ResourceModel\Db\AbstractDb $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $group)
{
$needInvalidating = $this->validate($group);
$objectResource = $proceed($group);
if ($needInvalidating) {
$this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID)->invalidate();
}
return $objectResource;
}
示例8: aroundSave
/**
* Ensure the index is invalidated when synonyms are updated.
*
* @param QueryModel $subject Saved query.
* @param \Closure $proceed Original save method.
*
* @return QueryModel
*/
public function aroundSave(QueryModel $subject, \Closure $proceed)
{
$needReindex = $subject->dataHasChangedFor('synonym_for');
$result = $proceed();
if ($needReindex) {
$this->indexerRegistry->get(ThesaurusIndexer::INDEXER_ID)->invalidate();
}
return $result;
}
示例9: aroundReindex
/**
* Reindex category's data after into search engine after reindexing the category
*
* @param \Magento\Catalog\Model\Category $subject The category being reindexed
* @param callable $proceed The parent function we are plugged on
* : Magento\Catalog\Model\Category::reindex()
*
* @return \Magento\Catalog\Model\Category
*/
public function aroundReindex(\Magento\Catalog\Model\Category $subject, callable $proceed)
{
$proceed();
if ($subject->getLevel() > 1) {
$categoryIndexer = $this->indexerRegistry->get(\Smile\ElasticsuiteCatalog\Model\Category\Indexer\Fulltext::INDEXER_ID);
if (!$categoryIndexer->isScheduled()) {
$categoryIndexer->reindexRow($subject->getId());
}
}
return;
}
示例10: processValue
/**
* Process flat enabled mode change
*
* @return void
*/
public function processValue()
{
if ((bool) $this->getValue() != (bool) $this->getOldValue()) {
if ((bool) $this->getValue()) {
$this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID);
$this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID);
$this->indexerState->save();
} else {
$this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)->setScheduled(false);
}
}
}
示例11: executeAction
/**
* Execute action for single entity or list of entities
*
* @param int[] $ids
* @return $this
*/
protected function executeAction($ids)
{
$ids = array_unique($ids);
$indexer = $this->indexerRegistry->get(static::INDEXER_ID);
/** @var Product\Action\Rows $action */
$action = $this->rowsActionFactory->create();
if ($indexer->isWorking()) {
$action->execute($ids, true);
}
$action->execute($ids);
return $this;
}
示例12: execute
/**
* Execute materialization on ids entities
*
* @param int[] $ids
* @return void
*/
public function execute($ids)
{
$indexer = $this->indexerRegistry->get(Flat\State::INDEXER_ID);
if ($indexer->isInvalid()) {
return;
}
/** @var Flat\Action\Rows $action */
$action = $this->rowsActionFactory->create();
if ($indexer->isWorking()) {
$action->reindex($ids, true);
}
$action->reindex($ids);
}
示例13: execute
/**
* Execute materialization on ids entities
*
* @param int[] $ids
* @return void
*/
public function execute($ids)
{
$indexer = $this->indexerRegistry->get(Flat\State::INDEXER_ID);
if ($indexer->isInvalid()) {
return;
}
/** @var Flat\Action\Rows $action */
$action = $this->rowsActionFactory->create();
if ($indexer->isWorking()) {
$action->reindex($ids, true);
}
$action->reindex($ids);
$this->getCacheContext()->registerEntities(\Magento\Catalog\Model\Category::CACHE_TAG, $ids);
}
示例14: filter
/**
* @param array $attributes
* @return array
*/
public function filter(array $attributes)
{
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() != StateInterface::STATUS_VALID) {
$tableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []);
$columns = $this->resource->getConnection()->describeTable($tableName);
foreach (array_keys($attributes) as $attributeCode) {
if (!isset($columns[$attributeCode])) {
unset($attributes[$attributeCode]);
}
}
}
return $attributes;
}
示例15: updateWebsites
/**
* Update websites for product action
*
* Allowed types:
* - add
* - remove
*
* @param array $productIds
* @param array $websiteIds
* @param string $type
* @return void
*/
public function updateWebsites($productIds, $websiteIds, $type)
{
if ($type == 'add') {
$this->_productWebsiteFactory->create()->addProducts($websiteIds, $productIds);
} elseif ($type == 'remove') {
$this->_productWebsiteFactory->create()->removeProducts($websiteIds, $productIds);
}
$this->setData(['product_ids' => array_unique($productIds), 'website_ids' => $websiteIds, 'action_type' => $type]);
$categoryIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID);
if (!$categoryIndexer->isScheduled()) {
$categoryIndexer->reindexList(array_unique($productIds));
}
}