How to add custom dropdown button to Admin Sales Order View in Magento 2

I’ve followed this link to add custom button in Admin Sales Order View in Magento 2, and it works great. Now I want to replace this button with 3 dropdown options button. Something like changing store scope in Admin Panel. I want this 3 buttons to run same controller method with different parameters.
How can i achieve this?
Thanks in advance.

Magento Asked by SebastianT on October 2, 2021

1 Answers

One Answer

This code works for me , try to look splitButton

class ViewPlugin

    public function beforeSetLayout(
        MagentoView $view,
        LayoutInterface $layout
    ) {
        $addButtonProps = [
            'id' => 'test',
            'label' => __('Test'),
            'class' => 'add',
            'button_class' => '',
            'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
            'options' => $this->getCustomActionListOptions(),

    protected function getCustomActionListOptions()
        /*list of button which you want to add*/
            'action_1'=>['label'=>__('Action 1'),'onclick'=>'setLocation("ACTION 1")'],
            'action_2'=>['label'=>__('Action 2'),'onclick'=>'setLocation("ACTION 2")'],
            'action_3'=>['label'=>__('Action 3'),'onclick'=>'setLocation("ACTION 3")']
        return $splitButtonOptions;

 <type name="MagentoSalesBlockAdminhtmlOrderView">
    <plugin name="addMyButton" type="MyModulePluginBlockAdminhtmlOrderView"/>

Correct answer by Kai on October 2, 2021

Add your own answers!

Related Questions

How can I hide the store switcher

4  Asked on February 4, 2021 by nria


Magento 2 – Cant use product factory in plugin

1  Asked on February 3, 2021 by black


How to create custom link for category?

3  Asked on January 30, 2021 by r_solanki


Magento 2 cache_invalidate loop

2  Asked on January 29, 2021 by tjitse


Magento 2.2 ssh commands not executed

1  Asked on January 29, 2021 by jilco-tigchelaar


How to add new or customize existing top header links in Magento?

4  Asked on January 26, 2021 by tallal-hassan


Upload SVG files as product image

0  Asked on January 26, 2021 by francesco-terreni


Add custom parameter in order’s item in rest api magento 2

0  Asked on January 25, 2021 by vijay-gupta


Ask a Question

Get help from others!

© 2021 All rights reserved.