🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Company Column in Abandoned Carts Report in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 5 min read

The default Magento 2 offers an abandoned carts report that lists all registered customers who have abandoned carts which is yet to be expired.

The abandoned carts report grid lists the below details:

  • Customer Name
  • Email Address
  • Number of products in the cart
  • Cart Subtotal
  • Applied Coupon
  • Date created
  • Date of the last update
  • IP address

These details can help the store owner track the reason for the cart abandonment and strive for customer retention. Cart abandonment can cost the business all the efforts, time, and money put to bring the valuable traffic to the site.

In March 2020, 88.05% of online shopping orders were abandoned – Statista

To reduce this number, the store owners employ various tactics using the customer data that is collected by configuring customer accounts in Magento 2 store.

It may happen, depending on the nature of the business, that some useful customer data is not included in the abandoned carts report in Magento 2 default grid.

For example, the customer’s company name that is collected during registration can be helpful to decide their purchase power and including it in the abandoned carts report can make the task easier.

To add company column in abandoned carts report in Magento 2 can be easy with the method given in this post. However, do not forget to first enable company name in customer account in Magento 2 from the admin panel.

The default Abandoned carts report in Magento 2 looks something like this:

Default Magento 2 Abandoned carts report

Stepwise method to add company column in abandoned carts report in Magento 2:

  1. Create registration.php file at app\code\Vendor\Module directory
<?php
use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_Module', __DIR__);
  1. Create module.xml file at app\code\Vendor\Module\etc directory
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"/>
</config>
  1. Create di.xml file at app\code\Vendor\Module\etc\adminhtml directory
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid" type="Vendor\Module\Block\Adminhtml\Shopcart\Abandoned\Grid" />
</config>
  1. Create Grid.php at app\code\Vendor\Module\Block\Adminhtml\Shopcart\Abandoned directory
<?php

namespace Vendor\Module\Block\Adminhtml\Shopcart\Abandoned;

class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
{
    protected $_quotesFactory;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Backend\Helper\Data $backendHelper,
        \Magento\Reports\Model\ResourceModel\Quote\CollectionFactory $quotesFactory,
        array $data = []
    ) {
        $this->_quotesFactory = $quotesFactory;
        parent::__construct($context, $backendHelper, $data);
    }

    protected function _construct()
    {
        parent::_construct();
        $this->setId('gridAbandoned');
    }

    protected function _prepareCollection()
    {
        $collection = $this->_quotesFactory->create();

        $filter = $this->getParam($this->getVarNameFilter(), []);
        if ($filter) {
            $filter = base64_decode($filter);
            parse_str(urldecode($filter), $data);
        }

        if (!empty($data)) {
            $collection->prepareForAbandonedReport($this->_storeIds, $data);
        } else {
            $collection->prepareForAbandonedReport($this->_storeIds);
        }

        $this->setCollection($collection);
        parent::_prepareCollection();
        if ($this->_isExport) {
            $collection->setPageSize(null);
        }
        $this->getCollection()->resolveCustomerNames();
        
        return $this;
    }

    protected function _addColumnFilterToCollection($column)
    {
        $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
        $skip = ['subtotal', 'customer_name', 'email'];

        if (in_array($field, $skip)) {
            return $this;
        }

        parent::_addColumnFilterToCollection($column);
        return $this;
    }

    protected function _prepareColumns()
    {
        $this->addColumn(
            'customer_name',
            [
                'header' => __('Customer'),
                'index' => 'customer_name',
                'sortable' => false,
                'header_css_class' => 'col-name',
                'column_css_class' => 'col-name'
            ]
        );

        $this->addColumn(
            'email',
            [
                'header' => __('Email'),
                'index' => 'email',
                'sortable' => false,
                'header_css_class' => 'col-email',
                'column_css_class' => 'col-email'
            ]
        );

        
        //add Company field
        $this->addColumn(
            'company',
            [
                'header' => __('Company'),
                'index' => 'company',
                'sortable' => false,
                'renderer' => \Meetanshi\Register\Block\Adminhtml\Grid\Column\Renderer\Company::class,
                'header_css_class' => 'col-company',
                'column_css_class' => 'col-company'
            ]
        );

        $this->addColumn(
            'items_count',
            [
                'header' => __('Products'),
                'index' => 'items_count',
                'sortable' => false,
                'type' => 'number',
                'header_css_class' => 'col-number',
                'column_css_class' => 'col-number'
            ]
        );

        $this->addColumn(
            'items_qty',
            [
                'header' => __('Quantity'),
                'index' => 'items_qty',
                'sortable' => false,
                'type' => 'number',
                'header_css_class' => 'col-qty',
                'column_css_class' => 'col-qty'
            ]
        );

        if ($this->getRequest()->getParam('website')) {
            $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
        } elseif ($this->getRequest()->getParam('group')) {
            $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
        } elseif ($this->getRequest()->getParam('store')) {
            $storeIds = [(int)$this->getRequest()->getParam('store')];
        } else {
            $storeIds = [];
        }
        $this->setStoreIds($storeIds);
        $currencyCode = $this->getCurrentCurrencyCode();

        $this->addColumn(
            'subtotal',
            [
                'header' => __('Subtotal'),
                'type' => 'currency',
                'currency_code' => $currencyCode,
                'index' => 'subtotal',
                'sortable' => false,
                'renderer' => \Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency::class,
                'rate' => $this->getRate($currencyCode),
                'header_css_class' => 'col-subtotal',
                'column_css_class' => 'col-subtotal'
            ]
        );

        $this->addColumn(
            'coupon_code',
            [
                'header' => __('Applied Coupon'),
                'index' => 'coupon_code',
                'sortable' => false,
                'header_css_class' => 'col-coupon',
                'column_css_class' => 'col-coupon'
            ]
        );

        $this->addColumn(
            'created_at',
            [
                'header' => __('Created'),
                'type' => 'datetime',
                'index' => 'created_at',
                'filter_index' => 'main_table.created_at',
                'sortable' => false,
                'header_css_class' => 'col-created',
                'column_css_class' => 'col-created'
            ]
        );

        $this->addColumn(
            'updated_at',
            [
                'header' => __('Updated'),
                'type' => 'datetime',
                'index' => 'updated_at',
                'filter_index' => 'main_table.updated_at',
                'sortable' => false,
                'header_css_class' => 'col-updated',
                'column_css_class' => 'col-updated'
            ]
        );

        $this->addColumn(
            'remote_ip',
            [
                'header' => __('IP Address'),
                'index' => 'remote_ip',
                'sortable' => false,
                'header_css_class' => 'col-ip',
                'column_css_class' => 'col-ip'
            ]
        );

        $this->addExportType('*/*/exportAbandonedCsv', __('CSV'));
        $this->addExportType('*/*/exportAbandonedExcel', __('Excel XML'));

        return parent::_prepareColumns();
    }

    /**
     * Get rows url
     *
     * @param \Magento\Framework\DataObject $row
     *
     * @return string
     */
    public function getRowUrl($row)
    {
        return $this->getUrl('customer/index/edit', ['id' => $row->getCustomerId(), 'active_tab' => 'cart']);
    }
}
  1. Create Company.php at app\code\Vendor\Module\Block\Adminhtml\Grid\Column\Renderer and add below code
<?php

namespace Vendor\Module\Block\Adminhtml\Grid\Column\Renderer;

use Magento\Backend\Block\Context;
use Magento\Customer\Model\CustomerFactory;
use Magento\Framework\DataObject;

class Company extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
    protected $customerFactory;

    public function __construct(Context $context, array $data = array(),CustomerFactory $customerFactory) {
        $this->customerFactory = $customerFactory;
        parent::__construct($context, $data);
    }

    public function render(DataObject $row)
    {
        $customerFactory = $this->customerFactory->create();

        $customerId = $row->getcustomer_id();

        $customer = $customerFactory->load($customerId);

        $Addresses = $customer->getAddresses();

        foreach ($Addresses as $address){
            return $address->getData('company');
        }

    }
}

That’s it.

Now, if you’ll check, the abandoned carts report in Magento 2 will have the company column added:

add company column in abandoned carts report in Magento 2

Also, do share the solution with the Magento community via social media.

Thanks.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.