1

In my custom extension i have tried modify section massaction name="listing_massaction". Just copy content from ui_component/sales_order_grid only keep actions neccessary but after clear cache, magento still combine all action from module magento_sales
Thinks i have done

Overwrite layout sales_order_index in my directory adminhtml/layout

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="content">
        <uiComponent name="sales_order_grid"/>
    </referenceContainer>
</body>

ui_component/sales_order_grid

<massaction name="listing_massaction">
        <action name="custom_print_orders" class="Company\Extension\Ui\Component\Action">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="type" xsi:type="string">custom_print_orders</item>
                    <item name="label" xsi:type="string" translate="true">Custom PDF - Print Orders</item>

                </item>
            </argument>
        </action>
        <action name="custom_print_invoices" class="Company\Extension\Ui\Component\Action">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="type" xsi:type="string">custom_print_invoices</item>
                    <item name="label" xsi:type="string" translate="true">Custom PDF - Print Invoices</item>

                </item>
            </argument>
        </action>
        <action name="custom_print_shipments" class="Company\Extension\Ui\Component\Action">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="type" xsi:type="string">custom_print_shipments</item>
                    <item name="label" xsi:type="string" translate="true">Easy PDF - Print Shipments</item>

                </item>
            </argument>
        </action>
        <action name="custom_print_creditmemos" class="Company\Extension\Ui\Component\Action">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="type" xsi:type="string">custom_print_creditmemos</item>
                    <item name="label" xsi:type="string" translate="true">Custom PDF - Print Creditmemos</item>

                </item>
            </argument>
        </action>
    </massaction>

Is there a way to remove original or disable action in massaction grid ui ?

1 Answer 1

4

You need to create component for that. So add class attribute like bellow code:

<massaction name="listing_massaction" class="Vendor\Module\Component\MassAction">
    ......
</massaction>

Vendor/Module/Component/MassAction.php

namespace Vendor\Module\Component;


class MassAction extends \Magento\Ui\Component\MassAction
{
    protected $removeType = ['cancel', 'hold_order'];
    /**
     * @inheritDoc
     */
    public function prepare()
    {
        $config = $this->getConfiguration();

        foreach ($this->getChildComponents() as $actionComponent) {
            $config['actions'][] = $actionComponent->getConfiguration();
        };

        $origConfig = $this->getConfiguration();
        if ($origConfig !== $config) {
            $config = array_replace_recursive($config, $origConfig);
        }

        $newConfigActions = [];
        foreach ($config['actions'] as $configItem) {
            if(in_array($configItem['type'], $this->removeType)) {
                continue;
            }

            $newConfigActions[] = $configItem;
        }

        $config['actions'] = $newConfigActions;

        $this->setData('config', $config);
        $this->components = [];

        parent::prepare();
    }
}
2
  • Work like a charm!
    – mrtuvn
    Jan 16, 2017 at 19:03
  • It's not working for me, my module in placed in app/code , magento version 2.3 Mar 22, 2019 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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