0

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 2

0

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>
1
  • 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> ```
    – jsnewbie21
    Commented Jun 19, 2023 at 8:46
0

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

3
  • Can you provide more details? ```
    – jsnewbie21
    Commented Jun 20, 2023 at 1:19
  • 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
    – jsnewbie21
    Commented Jun 26, 2023 at 0:21
  • Because your parameters in the __construct doesn't match the parent class
    – HoangHieu
    Commented Jun 26, 2023 at 3:15

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.