How to include Indexer to Magento 2

Here the following steps help you how to include indexer to Magento 2

Step 1: Form indexer class

Step 2: Form etc/indexer.xml files

In order to improve the performance of your store, Magento modifies the products and more. As data changes, the changed data should be refreshed-or reindexed. The Magento database table has a very sophisticated design that stores a lot of business data (including catalog data, price, user, stores, and more). In order to improve the performance of the store, it collects Magento data in additional table using encoders.

In this article, I will show you how to include indexer to Magento 2

  1. Form indexer class

namespace Webnexs\Training\Model\Indexer;

class Custom implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface


   public function executeFull();  //logic

   public function executeList($ids);   //logic

   public function executeRow($id);   //logic

   public function execute($ids);  //logic

  1. Form etc/indexer.xml files
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../Indexer/etc/indexer.xsd">

   <indexer id="Webnexs_indexer" view_id="Webnexs_indexer" class="Webnexs\Training\Model\Indexer\Custom">

       <title translate="true">Custom Indexer</title>

       <description translate="true">Custom Indexer</description>


<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Mview/etc/mview.xsd">

<view id=" Webnexs_indexer" class="Webnexs\Training\Model\Indexer\Custom" group="indexer">


       <table name="sales_order_flat" entity_column="order_id" />



Finally, announce the view of the table (Webnexs_indexer) that tracks the table (example: sales table). Please create a file. Please create the file Webnexs / Training / etc / mview.xml:

So when an order is placed, the custom indexer will calculate your logic based on the coding class.

The following steps are a short process that adds custom Indexer to Magento 2. With this guide, you can easily manage custom code on Magento 2. Each store has a custom Indexer for Magento 2 with many attributes

Last Update: April 7, 2018  

March 7, 2018   734   Nandini Ramachandran    Operations    
Total 2 Votes:

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

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