1

How can I add new column to customer grid ? I have created custom module. Below is my code.

path : vendor/module/view/adminhtml/layout/customer_group_index.xml

<body>
<referenceBlock name="adminhtml.catalog.product.set.grid.columnSet">
    <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.customer_group_columns">
          <arguments>
               <argument name="header" xsi:type="string" translate="true">Shipping Method</argument>
               <argument name="index" xsi:type="string">shipping_method</argument>
               <argument name="default" xsi:type="string">*</argument>
          </arguments>
    </block>          
</referenceBlock>
</body>
0

In my customer_group_index.xml

I added the code like this:

<referenceContainer name="content">
           <referenceBlock name="adminhtml.block.customer.group.grid.container">
               <referenceBlock name="adminhtml.block.customer.group.grid">
                   <referenceBlock name="adminhtml.customer.group.grid.columnSet">
                       <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.customer.group.grid.columnSet.new_column" as="new_column">
                           <arguments>
                               <argument name="header" xsi:type="string" translate="true">New Column</argument>
                               <argument name="new_column" xsi:type="string">new_column</argument>
                               <argument name="index" xsi:type="string">id</argument>
                               <argument name="column_css_class" xsi:type="string">col-id</argument>
                               <argument name="header_css_class" xsi:type="string">col-id</argument>
                           </arguments>
                       </block>
                   </referenceBlock>
               </referenceBlock>
           </referenceBlock>

And then you create a plugin on Magento\Customer\Model\ResourceModel\Group\Grid\ServiceCollection or even on groupRepository getList method, depending on your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy