In order to add your custom column QrCode
to the export csv, You need to override and extend the class Magento\Ui\Model\Export\ConvertToCsv
and rewrite the method getCsvFile
to include your custom field QrCode
source
https://github.com/magento/magento2/blob/2.3.3/app/code/Magento/Ui/Model/Export/ConvertToCsv.php
Sample Code (not tested, you must correct this based on your needs)
Your Module (DI) file
app/code/StackExchange/Override/etc/adminhtml/di.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Ui\Model\Export\ConvertToCsv" type="StackExchange\Override\Model\Export\ConvertToCsv" />
</config>
Overriden Class ConvertToCsv.php
app/code/StackExchange/Override/Model/Export/ConvertToCsv.php
<?php
/*
* Rewritten Export Model Convert To CSV class to include the custom field added to the grid
*
*
* @author Jerome Dennis <[email protected]>
*
*/
namespace StackExchange\Override\Model\Export\;
class ConvertToCsv extends \Magento\Ui\Model\Export\ConvertToCsv
{
/**
* Returns CSV file
*
* @return array
* @throws LocalizedException
*/
public function getCsvFile()
{
$component = $this->filter->getComponent();
$name = md5(microtime());
$file = 'export/'. $component->getName() . $name . '.csv';
// Here goes your code to include your custom field QrCode
return [
'type' => 'filename',
'value' => $file,
'rm' => true // can delete file after use
];
}
}
UPDATE
As alternate solutions, you can also use the solution provided here or this one