Created
March 7, 2018 15:14
-
-
Save magevision/f8c478882c1ba9f2d019752fc01063ae to your computer and use it in GitHub Desktop.
Add a Custom Button to Admin Sales Order View
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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