We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    If you want to add a custom button in the admin order view, then you can follow below steps.

    1. Create file di.xml on app/code/Magemonkeys/Custombutton/etc

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="MagentoBackendBlockWidgetContext">
            <plugin name="add_custom_button_sales_veiw" type="MagemonkeysCustombuttonPluginWidgetContext" sortOrder="1"/>
        </type>
    </config>

    2. Create file Context.php on app/code/Magemonkeys/Custombutton/Plugin/Widget

    <?php
    namespace MagemonkeysCustombuttonPluginWidget;
    
    class Context
    {
        protected $urlBuider;
        public function __construct(
            MagentoFrameworkAppActionContext $context,
            MagentoFrameworkAppRequestHttp $request,
            MagentoFrameworkUrlInterface $urlBuilder
        ) 
        { 
            $this->urlBuilder = $urlBuilder;
            $this->request = $request;
        }
        public function afterGetButtonList(
            MagentoBackendBlockWidgetContext $subject,
            $buttonList
        )
        {        
            if($this->request->getFullActionName() == 'sales_order_view'){
                $buttonList->add(
                    'custom_button',
                    [
                        'label' => __('Custom Button'),
                        'onclick' => 'setLocation('' . $this->getCustomUrl() . '')',
                        'class' => 'ship'
                    ]
                );
            }
    
            return $buttonList;
        }
    
        public function getCustomUrl()
        {        
            $order_id = $this->request->getParam('order_id');
            return $this->urlBuilder->getUrl('modulename/controllername/methodname',array('parameter'=>$order_id));
        }
        
    } ?>

     

    field_5bfb909c5ccae

      Get a Free Quote