0

I need to add new block to admin order create form (in totals section). First I tried to do it by adding sales_order_create_index.xml to my module and adding my block to

<referenceBlock name="data">

but it did not work and it's because all child blocks of "data" block are called in data.phtml with $block->getChildHtml() method.

UPDATE

Now I decited to use plugins instead, I added plugin to Magento\Sales\Block\Adminhtml\Order\Create\Data like this

class DataPlugin
{
    public function beforegetChildHtml($subject, $alias = '', $useCache = true){

       if($alias=='totals'){
          echo 'test';
       }

    }
}

And it's works. But how I can insert my block here instead of printing text

2

This is the way I can insert my custom block

namespace Exto\StoreCredit\Model\Plugin\Admin\Order\Create;

 class DataPlugin extends \Magento\Backend\Block\Template
 {

    public function beforegetChildHtml($subject, $alias = '', $useCache = true){
     if($alias=='totals'){
        echo $this->getLayout()
        ->createBlock('\Magento\Backend\Block\Template')
        ->setTemplate('Vendor_Module::test.phtml')
        ->toHtml();
     }

}

}

  • I need to create custom block in admin create form ....I follow ur steps ....But not working – Mano M Jul 31 '18 at 8:33

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.