0

I Have two custom attributes in my customer grid, named old_customer (1=>Yes,0=>No) and zone (1=>India, 2=>UK, 3=>Others ) , both attributes is_used_in_grid is true . but while I'm exporting in to the customer gird exporting option I'll get the result like below

Actual Result:

enter image description here

Expected Result :

enter image description here

Can someone please help me on this. Thanks in advance!!

1

2 Answers 2

0

Check if you have a module who overwritte this feature. If yes, disable it and try to re-export.

0

1.Create di.xml in your module [etc/di.xml]

<?xml version="1.0" encoding="UTF-8"?>
<config
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Ui\Model\Export\MetadataProvider">
        <plugin name="export_custmer_csv_row_data" type="VendorName\ModuleName\Model\Plugin\ExportRowDataModification" sortOrder="1" disabled="false"/>
    </type>
  1. Create Plugin Model [VendorName\ModuleName\Model\ExportRowDataModification.php]
<?php

namespace VendorName\ModuleName\Model\Plugin;

class ExportRowDataModification
{
    protected $resource;

    public function __construct(
        \Magento\Framework\App\ResourceConnection $resource
    )
    {
        $this->resource = $resource;
    }

    public function afterGetRowData($subject, $result, $document, $fields, $options)
    {
        $i = 0;

        foreach ($fields as $column) {

            //########## example formate
            if ($column === 'your_colum_name_place_here') {
                //do your logic here
            }

            //######### in my case

            //is old customer
            if ( $column === 'is_old_customer') {
                $result[$i] = (int)$result[$i] === 1 ? 'Yes' : 'No';
            }
            // change zone value to label
            if ($column === 'zone') {
                $zoneCollection = $this->zoneCollectionFactory->create();
                $zoneCollection->addFieldToFilter('zone_id', (int)$result[$i]);
                $zone = $zoneCollection->getFirstItem()->getName();
                $result[$i] = $zone;
            }

            $i++;
        }
        return $result;
    }
}

Thanks, @m2dubai for the knowledge

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.