Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit f9436b7

Browse files
atwixfirsterkeharper
authored andcommitted
#5218: Need info about structures in Adding a custom indexer (#6042)
* #5218: Need info about structures in Adding a custom indexer https://devdocs.magento.com/guides/v2.2/extension-dev-guide/indexing-custom.html https://devdocs.magento.com/guides/v2.3/extension-dev-guide/indexing-custom.html * Grammar updates @atwixfirster I made many grammatical changes. Please review my changes, especially the `shared_index` description,
1 parent 8641dc4 commit f9436b7

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

guides/v2.2/extension-dev-guide/indexing-custom.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,57 @@ Your custom indexer class should implement [\Magento\Framework\Indexer\ActionInt
2323

2424
### Indexer configuration
2525

26-
In the `etc` directory of your module, add `indexer.xml` with the following:
26+
Declare a new indexer process in the `etc/indexer.xml` file with the following attributes:
2727

28-
* indexer ID
29-
* indexer class name
30-
* indexer title
31-
* indexer description
32-
* indexer view ID
33-
* shared indexes, if any
28+
| Attribute | Required? | Description |
29+
| --- | --- | --- |
30+
| `id` | Yes | A unique indexer ID |
31+
| `class` | No | The class that processes indexer methods (`executeFull`, `executeList`, `executeRow`) |
32+
| `primary` | No | The source provider |
33+
| `shared_index` | No | Use this option to improve performance if your indexer is related to another indexer. In this [example]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/CatalogRule/etc/indexer.xml), 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 is reindexed. |
34+
| `view_id` | No | The ID of the view element that is defined in the `mview.xml` configuration file. |
35+
36+
For example,
37+
38+
```xml
39+
<?xml version="1.0"?>
40+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
41+
<indexer id="design_config_grid" view_id="design_config_dummy" class="Magento\Theme\Model\Indexer\Design\Config" primary="design_config">
42+
...
43+
</indexer>
44+
</config>
45+
```
3446

35-
Use the optional `shared_index=` parameter to improve performance if your indexer is related to another indexer. In this [example]({{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/CatalogRule/etc/indexer.xml){:target="_blank"}, if [catalog](https://glossary.magento.com/catalog) rule product needs to be reindexed, but other catalog product rule index is up-to-date, then only catalog rule product is reindexed.
47+
An indexer process can also have the following optional parameters:
48+
49+
| Parameter | Description |
50+
| --- | --- |
51+
| `description` | The description of indexer to be displayed on the `System` > `Tools` > `Index Management` page. |
52+
| `fieldset` | Describes the fields, source, and data provider of the flat index table. |
53+
| `saveHandler` | An extension point. The class for processing (deleting, saving, updating) items when indexing. |
54+
| `structure` | The class that processes (creates, removes) flat index tables. |
55+
| `title` | The title of indexer to be displayed on the `System` > `Tools` > `Index Management` page. |
56+
57+
For example:
58+
59+
```xml
60+
<?xml version="1.0"?>
61+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
62+
<indexer ...>
63+
<title translate="true">Design Config Grid</title>
64+
<description translate="true">Rebuild design config grid index</description>
65+
66+
<fieldset name="design_config" source="Magento\Theme\Model\ResourceModel\Design\Config\Scope\Collection"
67+
provider="Magento\Theme\Model\Indexer\Design\Config\FieldsProvider">
68+
<field name="store_website_id" xsi:type="filterable" dataType="int"/>
69+
<field name="store_group_id" xsi:type="filterable" dataType="int"/>
70+
<field name="store_id" xsi:type="filterable" dataType="int"/>
71+
</fieldset>
72+
<saveHandler class="Magento\Framework\Indexer\SaveHandler\Grid"/>
73+
<structure class="Magento\Framework\Indexer\GridStructure"/>
74+
</indexer>
75+
</config>
76+
```
3677

3778
All indexers related to a [module](https://glossary.magento.com/module) should be declared in one file.
3879

0 commit comments

Comments
 (0)