I want to add a custom attribute to the admin customer grid. For that, I have added two attributes using ui_component.
The columns show up in the grid but without data from customer_grid_flat
(because Magento 2 uses a flat grid table for retrieving data to the grid).
I found the following answer on StackExchange:
add a custom column in customer grid
According to that, I added an indexer.xml
file to my custom module:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
<indexer id="customer_grid" view_id="customer_dummy" class="Magento\Framework\Indexer\Action\Entity" primary="customer">
<fieldset name="customer" source="Magento\Customer\Model\ResourceModel\Customer\Collection" provider="Magento\Customer\Model\Indexer\AttributeProvider">
<field name="webshop" xsi:type="filterable" dataType="int"/>
<field name="aktiv" xsi:type="filterable" dataType="int"/>
</fieldset>
</indexer>
</config>
and executed php bin/magento indexer:reindex customer_grid
.
Now, I face two different errors in two different conditions:
Please note above indexer attribute
view_id
. it is customer_dummy (Which is default to native customer module). if I use the sameview_id
name in my custom module I get error Customer grid index is locked by another reindex process. SkippingIf I use a different
view_id
name and executephp bin/magento indexer:reindex customer_grid
then it shows view_id (in my case it justdummy
) view does not exist.