Is there a way to rename the default export.csv filename to another filename? I'm using the magento 2 export in my listing.xml
2 Answers
yeah, I think there is a possibility .Try this,
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/listing.xsd">
<export entity="Magento\Catalog\Model\Product" class="Magento\ImportExport\Model\Export\Adapter\Csv" fileName="custom_export.csv">
<!-- Other export configuration -->
</export>
</listing>
-
not working. Error: Element 'export': This element is not expected ``` <export entity="Magento\Catalog\Model\Product" class="Magento\ImportExport\Model\Export\Adapter\Csv" fileName="custom_export.csv"> <exportButton name="export_button"/> </export> ``` Commented Jun 19, 2023 at 8:46
The default Magento hard coded the file name "exported.csv" in this file
vendor/magento/module-ui/Controller/Adminhtml/Export/GridToCsv.php:70
You can create a composer patch or rewrite this controller by your own for editing the file name
-
-
I tried this.. but it gives me the Interceptor error.. Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Thecoachsmb\Blog\Controller\Adminhtml\Export\GridToCsv\Interceptor, Argument 1 passed to Thecoachsmb\Blog\Controller\Adminhtml\Export\GridToCsv\Interceptor::__construct() must be an instance of Magento\Backend\App\Action\Context, instance of Magento\Framework\View\Element\UiComponent\Context given, called in C:\xampp\htdocs\magento2_\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php on line 121 Commented Jun 26, 2023 at 0:21
-
Because your parameters in the __construct doesn't match the parent class Commented Jun 26, 2023 at 3:15