Вопрос

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.

Это было полезно?

Решение

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.

Другие советы

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().

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top