2

By default, magento provides two options CSV and XML file format for the export.

So how can I keep one of them for export in ui component based listing ?

3

Add class attribute in ui_component listing xml

<exportButton name="export_button" class="Vendor\Module\Component\ExportButton">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="selectProvider" xsi:type="string">......ids</item>
        </item>
    </argument>
</exportButton>

Vendor/Module/Component/ExportButton.php

<?php
namespace Vendor\Module\Component;


class ExportButton extends \Magento\Ui\Component\ExportButton
{
    private $removeOption = 'cvs';
    /**
     * @return void
     */
    public function prepare()
    {
        $config = $this->getData('config');

        if (isset($config['options'])) {
            $options = [];
            if(isset($config['options'][$this->removeOption])) {
                unset($config['options'][$this->removeOption]);
            }

            foreach ($config['options'] as $option) {
                $option['url'] = $this->urlBuilder->getUrl($option['url']);
                $options[] = $option;
            }
            $config['options'] = $options;
            $this->setData('config', $config);
        }
        parent::prepare();
    }
}
  • its working fine for me in 2.3.3 but not Working for me in 2.3.0 ... Need Help – Waqar Ali Nov 13 '19 at 12:54

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.