Skip to content

Instantly share code, notes, and snippets.

@magevision
Created March 7, 2018 15:14
Show Gist options
  • Save magevision/f8c478882c1ba9f2d019752fc01063ae to your computer and use it in GitHub Desktop.
Save magevision/f8c478882c1ba9f2d019752fc01063ae to your computer and use it in GitHub Desktop.
Add a Custom Button to Admin Sales Order View
<?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="Magento\Sales\Block\Adminhtml\Order\View">
<plugin name="sales_order_adminhtml_view_custom_button_plugin" type="MageVision\Blog27\Plugin\Sales\Block\Adminhtml\Order\View"/>
</type>
</config>
<?php
namespace MageVision\Blog27\Plugin\Sales\Block\Adminhtml\Order;
use Magento\Sales\Block\Adminhtml\Order\View as OrderView;
class View
{
public function beforeSetLayout(OrderView $subject)
{
$subject->addButton(
'order_custom_button',
[
'label' => __('Custom Button'),
'class' => __('custom-button'),
'id' => 'order-view-custom-button',
'onclick' => 'setLocation(\'' . $subject->getUrl('module/controller/action') . '\')'
]
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment