This is a simple tutorial to show you how to add a new action for orders in the Order View page within the Admin Panel.

In order to accomplish this requirement, we created a module called Codealist_OrderViewButton.

  1. The first step will be to create a di.xml file within your-module/etc/adminhtml directory with the following content:

  2. As you can see, we declared a plugin for the class Magento\backend\Block\Widget\Button\Toolbar, which doesn’t apply only for the Order View. After doing this, we need to create our plugin class an intercept the desired method.
    Create a new file in your-module/Plugin/Adminhtml/AddCustomButton.php with the following content:

  3. Now we need to create a custom route and a controller action with something specific action for our button. For that we will declare are custom route.

  4. And finally let’s create our controller class in your-module/Controller/Adminhtml/Order/Index.php


    Now all you need to do is to install your module, go to view any order on the admin panel and then you’ll see your new Button at the top of the page.

Leave a comment