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.

2
  • Try this app/code/Vendor/ModuleName/view/base/ui_component/etc/definition.xml Commented Apr 2, 2019 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
    Commented Apr 2, 2019 at 6:23

2 Answers 2

2

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

Update Feb 2021

The issue will not be fixed by Magento. So it is just not possible.

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.

0

I think it's not possible to override or extend definition.xml in a simple way. But if you want to add a custom formElement definition or something like that try to use plugin for \Magento\Ui\Config\Reader\Definition\Data method get().

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.