cancel
Showing results for 
Search instead for 
Did you mean: 

Order Mass Action Dropdown Sort Order

Order Mass Action Dropdown Sort Order

I am trying to reorder the order mass action menu, I can change the Magento menu options in 

 

/vendor/magento/module-sales/view/adminhtml/ui_component/sales_order_grid.xml

 

but I want to put some of my Modules at the top of the list and I cant figure out what template or xml file I need to change

 

Thanks

9 REPLIES 9

Re: Order Mass Action Dropdown Sort Order

HI @miller75,

but I want to put some of my Modules at the top of the list and I cant figure out what template or xml file I need to change
VT:  What do you mean? Do you want any any different link in Top navigation menu?

If poosible please share screenshot. 

 

OR 

IF you want add some more action from your custom modules on the top then you will found same file in that custom modules/extension as well.

MODULE PATH/view/adminhtml/ui_component/sales_order_grid.xml

There you can add sort order in the action list.

<item name="sortOrder" xsi:type="number">10</item>

You can change number as per your required sequence. 

I hope it will help you!

Re: Order Mass Action Dropdown Sort Order

menu.jpg

 

 

For example Print Orders is a 3rd party extension and I want this at the top of the list

Re: Order Mass Action Dropdown Sort Order

Hi @miller75,

Got it, I just added my comment in the same post. 

Please try once.  

Re: Order Mass Action Dropdown Sort Order

For example : 

<?xml version="1.0" encoding="UTF-8"?>
    <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
      <container name="listing_top">
        <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="actions" xsi:type="array">
                        <item name="delete" xsi:type="array">
                            <item name="type" xsi:type="string">delete</item>
                            <item name="label" xsi:type="string" translate="true">Delete</item>
                            <item name="url" xsi:type="string">sales/order/massDelete</item>
                            <item name="sortOrder" xsi:type="number">10</item>
                        </item>
                    </item>
                </item>
            </argument>
        </massaction>
    </container>
  </listing>

Re: Order Mass Action Dropdown Sort Order

Thanks for the reply, I have tried adding the sort order but it doesn't change anything

Re: Order Mass Action Dropdown Sort Order

Did you flushed the cache after change?

php bin/magento cache:flush

Re: Order Mass Action Dropdown Sort Order

Yes flushed the cache, does it make a difference that I am on 2.3.2?

Re: Order Mass Action Dropdown Sort Order

This can be done using a plugin:

adminhtml/di.xml:

 

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Ui\Component\MassAction">
        <plugin name="CustomVendor_CustomActions::sort_actions" type="CustomVendor\CustomActions\Plugin\Component\MassAction" sortOrder="100"/>
    </type>
</config>

Plugin\Component\MassAction.php

 

<?php

namespace CustomVendor\CustomAction\Plugin\Component;

use Magento\Framework\App\RequestInterface;

class MassAction
{

    /** @var RequestInterface */
    private $_request;

    /**
     * MassAction constructor.
     * @param RequestInterface $request
     */
    public function __construct(
        RequestInterface  $request
    )
    {
        $this->_request = $request;
    }

    /**
     * @param ComponentMassAction $massAction
     */
    public function afterPrepare(ComponentMassAction $massAction)
    {
        if ($this->_request->getFullActionName() === 'sales_order_index') {

            $config = $massAction->getData('config');

            if (isset($config['actions']) && $config['actions']) {

                $count = 0;

                foreach (["custom_action_1" => 0, "custom_action_2" => 1] as $actionType => $position) {

                    /** @var $config mixed[][] */
                    foreach ($config['actions'] as $key => $action) {

                        if ($action['type'] == $actionType) {
                            $newPosition = max((int) $position, $count);
                            $this->moveElement($config['actions'], $key, $newPosition);
                            break;
                        }
                    }
                    $count++;
                }

                $massAction->setData('config', $config);
            }
        }
    }

    /**
     * @param array $actions
     * @param int $oldPosition
     * @param int $newPosition
     */
    public function moveElement(&$actions, $oldPosition, $newPosition)
    {
        $outputArray = array_splice($actions, $oldPosition, 1);
        array_splice($actions, $newPosition, 0, $outputArray);
    }

}

 

I had no luck using module sequence or sortOrder param in XML to achieve this. Plugin is the only method that worked for me in Magento 2.4.3.

Re: Order Mass Action Dropdown Sort Order

Hello.

I have a custom mass action with sub menu and all my submenu apear very low in the screen, it leaves a space between the manu and the submenu of the mass action.

 

Is there any way to change this. Thanks

please check the image.

submenu problemsubmenu problem