I want to add a Customer Group in a Customer grid during order creation For Magento2. I made


like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="adminhtml.customer.grid.container">
                <argument name="dataSource" xsi:type="object">\[vendor]\[module]\Model\ResourceModel\Order\Customer\Collection</argument>
        <referenceBlock name="adminhtml.customer.grid.columnSet">
            <block class="Magento\Backend\Block\Widget\Grid\Column" as="group" after="name">
                    <argument name="header" xsi:type="string" translate="true">Group</argument>
                    <argument name="index" xsi:type="string">customer_group</argument>

This creates new empty column after column "Name". But I don't know how I can get value of "Customer Group" in this file:


1 Answer 1


Your class needs to extend original dataSource and joinField to get customer group name, like this code below:


namespace Walish\CustomModule\Model\ResourceModel\Order\Customer;

class Collection extends \Magento\Sales\Model\ResourceModel\Order\Customer\Collection
    protected function _initSelect()


        return $this;
  • It works for me. But first parameter of joinField() should be same as index in XML file. In this case 'group_name' should change to 'customer_group' . Commented May 14, 2019 at 8:21
  • 1
    Edited my answer.
    – Quan Le
    Commented May 14, 2019 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.