Magento 2: Add customer in grid on category edit page at admin panel

Magento 2: Add customer in grid on category edit page at admin panel

September 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2: Add customer in grid on category edit page at admin panel

How to Create a Custom Customer List for Magento Admin

As an e-commerce developer working with Magento, you might find yourself needing to create a custom customer list within the admin panel. This can be useful for various reasons, such as segmenting customers based on specific criteria or providing a different interface for customer management. In this guide, we’ll walk through how to set up a custom customer listing in your Magento 2 store.

Why Create a Custom Customer List?

Before diving into the technical details, let’s consider why you might want to create a custom customer list:

  1. Segmentation: You can filter customers based on specific attributes (like purchase history or sign-up date) for targeted marketing campaigns.
  2. Simplified Interface: For stores with many customers, a simplified interface can make management more efficient.
  3. Access Control: If certain users need to access only specific customer groups, a custom list provides better control.

Setting Up the Custom Customer Listing

The process involves creating a new data provider and corresponding XML files for the listing. Here’s a step-by-step breakdown:

1. Create the Data Provider

In your module’s DataProvider directory (e.g., Vendor/Module/DataProvider/Product), create a new file named after your listing, like CustomCustomerList.php. This will be your custom data provider.

namespace Vendor\Module\Ui\DataProvider;

use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;

class CustomCustomerList extends SearchResult
{
    protected $_preparedColumns = [];

    public function __construct(
        RequestInterface $request,
        CustomerCollectionFactory $collectionFactory,
        array $meta = [],
        array $data = []
    ) {
        $this->meta = $meta;
        $this->data = $data;
        $this->_request = $request;
        $this->collection = $collectionFactory->create();
    }

    public function getData()
    {
        // Add your custom filtering or sorting logic here if needed
        return parent::getData();
    }
}

In this example, we’re using the built-in Customer collection. You can modify the collection based on your specific needs.

2. Configure the Data Provider in di.xml

Next, you need to configure your data provider in your module’s di.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Vendor\Module\Ui\DataProvider\Product\Modifier\CustomCustomerList" />
</config>

3. Create the Listing XML

In your module’s view/adminhtml/ui_component directory, create a new file named after your listing, like custom_customer_listing.xml. This will define the layout and fields for your custom customer list.

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">custom_customer_listing.custom_customer_listing_data_source</item>
            <item name="deps" xsi:type="string">custom_customer_listing.custom_customer_listing_data_source</item>
        </item>
    </argument>
    <dataSource name="custom_customer_listing_data_source">
        <!-- Add your data source configuration here -->
    </dataSource>
    <columns name="customer_columns" class="Magento\Customer\Ui\Component\Listing\Columns">
        <!-- Define your columns and their configurations here -->
    </columns>
</listing>

The argument section defines the provider for your data, and the columns element lets you specify which customer fields to display.

Displaying Your Custom Customer List

To actually display this custom list in your admin panel:

  1. Create a new page layout XML file under app/code/Vendor/Module/view/adminhtml/layout.
  2. Define an adminhtml_customer_listing_index.xml file with the following content:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account_index"/>

    <referenceContainer name="content">
        <block class="Magento\Customer\Block\Adminhtml\Customer\Grid" before="-" template="Vendor_Module::custom_customer_listing.phtml"/>
    </referenceContainer>
</page>

This links your custom listing PHTML file to the customer account index page.

  1. Create a custom_customer_listing.phtml file under app/code/Vendor/Module/view/adminhtml/templates/customer.
  2. In this PHTML file, you can use Magento’s built-in grid rendering or create a custom layout for your list.

And that’s it! You now have a custom customer listing in your Magento admin panel using Laravel Company’s best practices.

Remember to replace placeholders like Vendor, Module, and specific file names with the actual details of your project. This guide provides a basic structure, but you’ll need to adapt it based on your store’s requirements.

Please note that this is a simplified example. In a real-world scenario, you may need to handle additional aspects like security permissions, translations, or more complex filtering.

For further customization and best practices for Magento development, I recommend checking out the resources at Laravel Company (https://laravelcompany.com). They provide in-depth guides on Magento 2 themes, extensions, and development strategies.

Magento 2 Catalog Extensions Admin

Our network