3

I use the code below to add after order_info tab, but I want when I display the order details the active tab to be order_info.

<referenceBlock name="sales_order_tabs">
  <action method="addTabAfter">
    <argument name="name" xsi:type="string">name</argument>
    <argument name="block"xsi:type="string">VENDOR\MODULE\Block\Adminhtml\Order\View\Tab\Custom</argument>
    <argument name="after" xsi:type="string">order_info</argument>
  </action>
</referenceBlock>
1

I found the solutions!

It was in Controller Action on execute function was set

$this->_translateInline->processResponseBody($html)

and after I removed, the order_info remain selected tab

Bellow it is my code for execute function

public function execute(){

    $this->_initOrder();
    $layout = $this->layoutFactory->create();
    // Yes, this is the same block class that we defined in sales_order_view.xml
    $html = $layout->createBlock('VENDOR\MODULE\Block\Adminhtml\Order\View\Tab\Custom')
        ->toHtml();
    // $this->_translateInline->processResponseBody($html);
    /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
    $resultRaw = $this->resultRawFactory->create();
    $resultRaw->setContents($html);
    return $resultRaw;
}
0

Just make sure your module loads after Magento_Sales

Add the following code into your module.xml for this:

<module name="Vendor_Module" setup_version="2.0.0">
    <sequence>
        <module name="Magento_Sales"/>
    </sequence>
</module>

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.