Mageto2: The Indexer Configuration

Indexer Configuration In Magento 2 - SBDEVBLOG

We have created a custom indexer. Now, let’s understand the configuration to create a custom indexer.

We have taken care of the following points while creating a custom indexer.

  • Indexer Configuration
  • MView Configuration
  • Indexer Logic

Mageto2: The Indexer Configuration


idYesIt is the id of the indexer, which must be unique.
classNoThe class that processes indexer methods (executeFull, executeList, executeRow and execute)
primaryNoIt is the source of provider
shared_indexNoUse this option to improve performance if your indexer is related to another. You can take an example from the catalog product catalog rule’s indexer. If the Catalog product rule index needs to be reindexed, but other catalog product rule indexes are up-to-date, then only the Catalog product rule index needs to be reindexed.
view_idThe id which we define in the view.xml file
indexer.xml’s indexer tag

The indexer.xml also has the parameters, so let’s look into it.

descriptionThe description of the indexer is to be displayed on the System > Tools > Index Management page.
Describes the fields, source, and data provider of the flat index table.
saveHandlerThe class for processing (deleting, saving, updating) items when indexing.
structureThe class that processes (creates, removes) flat index tables.
titleThe title of indexer to be displayed on the System > Tools > Index Management page
parameter’s of indexer tag


mview.xml contains the indexer view id, indexer class, the database name that the indexer will track, and the column data to be sent to the indexer.

The View Node

The view node defines an indexer. It contains attributes given below:

idThis attribute contains the name of the indexer table.
classThis contains a class that will be responsible for executing the indexer.
groupIt defines the indexer group.

The Subscription Node

This node contains children nodes with the name table. This node observes changes in given tables in the children node.

The Table Node

This node defines a table to track changes.

nameThis attribute contains the table name
entity_columnThis attribute defines field name to be re-indexer

Indexing can be done by cron as well as the command: php bin/magento indexer:reindex

Re-indexing can be performed in two modes: 1) Update On Save and 2) Update By Schedule.

  1. Update On Save: Indexer table will be updated immediately on saving or updating data on tables
  2. Update By Schedule: The index table will be updated based on the cron job schedule.

Note: Magento doesn’t support the update by schedule on the customer_grid indexer. Apart from customer_grid, You may set the update by schedule on all Magento’s indexers.

For customer_grid, You may set the Update on Save model. You may also re-index by using the command php bin/magento indexer:reindex customer_grid

I hope you like the post and have more clarity about the configuration of the indexer.

Please subscribe to the SbDevBlog. Use the comment box to share your feedback. Thank You!

Check out the post for re-index programmatically.

Would you like to invalidate your indexer programmatically? Then, please click on the link I’ve given and get the job done.

Thanks for the reading Mageto2: The Indexer Configuration

Download Custom Indexer Source Code

Note: Please verify the code of this blog and the relevant git repository before using it in production.
sb dev blog adobe commece Magento 2


One thought on “Mageto2: The Indexer Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *