1

I am developing an extension to add another export format option in order toolbar in export button dropdown.

What I found yet is that there are two options here (Sales Order Toolbar) right now:

a) CSV
b) Excel XML

Here I want to add another option here called "MOM" which will create a new csv format of order.

I found that above two options comes from following path:

vendor\magento\module-ui\view\base\ui_component\etc\definition.xml

But I don't know how to override it in my module. I don't want to edit core files.

  • Try this app/code/Vendor/ModuleName/view/base/ui_component/etc/definition.xml – Prathap Gunasekaran Apr 2 at 6:22
  • You can override it by copying definition.xml to your custom module from this path: >vendor\module\view\base\ui-component\etc\definition.xml – fmsthird Apr 2 at 6:23
1

Add to all grids

If you want to add your custom export format to all grids at once, like it is done with the default xml and csv exports, then have a look at the following GitHub issue, at the moment there is a bug to accomplish this: https://github.com/magento/magento2/issues/24543#issuecomment-530265065

Add to specific grid

If you want to add only to a specific grid (e.g. order grid) , then use the following:

Add file {vendor} /{module} /view/adminhtml/ui_component/sales_order_grid.xml with the following content to your module:

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <listingToolbar name="listing_top">
        <exportButton name="export_button">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="options" xsi:type="array">
                        <item name="custom_csv" xsi:type="array">
                            <item name="value" xsi:type="string">custom_csv</item>
                            <item name="label" xsi:type="string" translate="true">Custom CSV</item>
                            <item name="url" xsi:type="string">{your_frontname}/export/gridToCustomCsv</item>
                        </item>
                    </item>
                </item>
            </argument>
        </exportButton>
    </listingToolbar>
</listing>

Now create a controller to handle the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.