---
title: "How to create custom indexer in Magento 2 ?"
url: "https://dolphinwebsolution.com/how-to-create-custom-indexer-in-magento-2"
date: "2020-10-10T11:36:19+05:30"
modified: "2023-08-28T06:05:29+05:30"
author:
  name: "Jay Rangnani"
categories:
  - "Magento"
tags:
  - "indexer"
word_count: 489
reading_time: "3 min read"
summary: "In simple words, Index is a data structure that helps to improve the performance of data searches and queries on a table.
Steps to create custom indexer in Magento 2
A) Create an indexer class
..."
description: "In simple words, Index is a data structure that helps to improve the performance of data searches and queries on a table."
keywords: "custom indexer in Magento 2,indexer in Magento 2,Magento 2 custom indexer,Magento 2 indexer,custom indexer, indexer, Magento"
language: "en"
schema_type: "Article"
---

# How to create custom indexer in Magento 2 ?

_Published: October 10, 2020_  
_Author: Jay Rangnani_  

![](https://dolphinwebsolution.com/wp-content/uploads/2023/02/Custom-Indexer-1024x512.jpg)

In simple words, Index is a data structure that helps to improve the performance of data searches and queries on a table.

### Steps to create custom indexer in Magento 2
A) Create an indexer class

B) Create etc/indexer.xml file

C) Create etc/mview.xml file

### A) Create an indexer class
The custom indexer class must implement \\Magento\\Framework\\Indexer\\ActionInterface and the indexer should be able to perform three types of operations:

1 ) executeRow($id)
– Processing a single entry from a dictionary.
2 ) executeList($ids)
– Processing a set of dictionary entries
3 ) executeFull()
– Processing all entities from a specific dictionary.

\\Magento\\Framework\\Mview\\ActionInterfaceinterface contains the methods that are applied for the Update By [Schedule mode](https://support.magento.com/hc/en-us/articles/360040227191-Indexers-Update-On-Schedule-optimizes-Magento-performance-) of an indexation

```
<?php

namespace Dolphin\CustomIndexer\Model;

use Magento\Framework\Indexer\ActionInterface as IndexerInterface;
use Magento\Framework\Mview\ActionInterface as MviewInterface;

class Indexer implements IndexerInterface, MviewInterface
{

    /**
     * It's used by mview. It will execute when process indexer in "Update on schedule" Mode.
     */
    public function execute($ids)
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Execute Method Call When Update on Schedule');
    }

    /**
     * Add code here for execute full indexation
     */
    public function executeFull()
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Execute Full Method Call When Re index using command line');
    }

    /**
     * Add code here for execute partial indexation by ID list
     */
    public function executeList(array $ids)
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Execute List Method Call When partial indextion by id list');
    }

    /**
     * Add code here for execute partial indexation by ID
     */
    public function executeRow($id)
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Execute Row Method Call When partial indextion by specific id');
    }
}
```

### B) Create etc/indexer.xml file
Create the indexer.xml file inside the etc folder of the module. Dolphin\\CustomIndexer\\etc\\indexer.xml

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
    <indexer id="dolphin_customindexer_indexer" view_id="dolphin_customindexer_view" class="Dolphin\CustomIndexer\Model\Indexer">
        <title translate="true">Custom Index Title</title>
        <description translate="true">Custom Index Description</description>
    </indexer>
</config>
```

### C) Create etc/mview.xml file
```
<?xml version="1.0" encoding="UTF-8"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
    <view id="dolphin_customindexer_view" class="Dolphin\CustomIndexer\Model\Indexer" group="indexer">
    <subscriptions>
      <table name="uploadtool_inventory" entity_column="id" />
    </subscriptions>
    </view>
</config>
```


---

_View the original post at: [https://dolphinwebsolution.com/how-to-create-custom-indexer-in-magento-2](https://dolphinwebsolution.com/how-to-create-custom-indexer-in-magento-2)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 06:54:27 UTC_  
