I have another problem.

When you edit an order (admin) you will get here:

enter image description here The buttons above, marked with the red line, are generated here:



// @codingStandardsIgnoreFile

<?php if ($block->getChildHtml()):?>
    <div data-mage-init='{"floatingHeader": {}}' class="page-actions" <?php /* @escapeNotVerified */ echo $block->getUiId('content-header') ?>>
        <?php echo $block->getChildHtml(); ?>
<?php endif; ?>

I want to add a custom button "Bestellschein" there. How can I do that?

Edit: Where can I code the logic of the button?

1 Answer 1


One way you can do that is by adding a plugin to your project. Create:




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Custom_Module" setup_version="1.0.0"/>


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Backend\Block\Widget\Button\Toolbar">
        <plugin name="buttons_plugin" type="Custom\Module\Plugin\Buttons" />


namespace Custom\Module\Plugin;

class Buttons
public function beforePushButtons(
    \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject,
    \Magento\Framework\View\Element\AbstractBlock $context,
    \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
) {

    $this->_request = $context->getRequest();
    if($this->_request->getFullActionName() == 'sales_order_view'){
            ['label' => __('My Button'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'],


After run:

  • php bin/magento setup:upgrade
  • php bin/magento cache:flush
  • it worked. Where can I code the logic of the button? Mar 13, 2018 at 14:50
  • you will need to create a new route and a controller that will handle the request
    – Adrian Z.
    Mar 13, 2018 at 15:32
  • I want the button to start a download Mar 13, 2018 at 15:34
  • you will need to post another question, because that is another topic
    – Adrian Z.
    Mar 13, 2018 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.