enter image description here

I am adding a new button with Add Products button at:

Sales->Order->Create New Order->New Add Product Button as shown in screenshot!

I searched for the relevant referenceContainer in vendor but all in vain. Is this approach right or have to do it by some other way ?


In vendor, button html renders in Magento\Sales\Block\Adminhtml\Order\Create\Items class from getButtonsHtml() method.

You can write after plugin method and add your custom button in your custom plugin.

Also you can try to write after plugin for method addButton() of Magento\Sales\Block\Adminhtml\Order\Create\Items class.

Note : "Add Products" button comes from js vendor/magento/module-sales/view/adminhtml/web/order/create/scripts.js

Following code will help you to create plugin.

Create di.xml file in etc\adminhtml folder and add follwing code

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="Magento\Sales\Block\Adminhtml\Order\Create\Items">
        <plugin name="vendor-module-order-create-items-block" type="Vendor\Module\Plugin\Order\Create\Items" sortOrder="100" />

After di.xml you need to create your plugin file Items.php at location Vendor\Module\Plugin\Order\Create as below:

namespace Vendor\Module\Plugin\Order\Create;

class Items
    public function afterGetButtonsHtml(\Magento\Sales\Block\Adminhtml\Order\Create\Items $subject, $result)
        $url = 'http://www.google.com';
        $result .= $subject->getLayout()->createBlock(
                ['label'=>'Add New Products', 'type'=>'button', 'id'=> 'add_new_products', 'class' => 'action-secondary action-add', 'on_click'=>"window.location.href='" . $url . "'"]
        return $result;
  • Can you give an example for it? what I understand is it will done by plugin. Can you explain more. – Ajwad Syed Nov 12 '18 at 12:39
  • Yes you understood correct, you need to write plugin afterGetButtonsHtml() of class Magento\Sales\Block\Adminhtml\Order\Create\Items – Ranjit Shinde Nov 12 '18 at 12:41
  • Kindly write plugin for me in answer, i am doing this for the first time. – Ajwad Syed Nov 12 '18 at 12:45
  • @AjwadTaqvi I have updated my answer. Please check. – Ranjit Shinde Nov 12 '18 at 13:16
  • Thanks @RanjitShinde it worked! Can you please also guide in this next step ? magento.stackexchange.com/questions/249716/… – Ajwad Syed Nov 12 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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