2

We had a custom block injected in the adminhtml section. This block is managed in a module (let's call it Vendor/Module) & it was working fine in Magento 2.1.*, following this methodology magento 2 - How to create a custom "admin" block and display it on an existing Admin page?

After upgrading to 2.2 the block has disappeared

I have checked for the concrete layout (in our case sales_order_view.xml) for any structural changes in the new version, but containers & blocks look the same as we had in 2.1.*

Any ideas for this?

This is the concrete layout file which worked fine in 2.1.*

app/code/Vendor/Module/view/adminhtml/layout/sales_order_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
 <referenceBlock name="order_info">
 <block class="Vendor\Module\Block\Adminhtml\Sales\Order\View\Form" name="our_unique_block_name" template="Vendor_Module::our_template.phtml"/>
 </referenceBlock>
 </body>
</page> 

UPDATE

Bounty: provide XML code to inject a block inside sales_order_view adminhtml layout, explaining how to place it in different sections of the page

Andhi Irawan
9821 gold badge14 silver badges28 bronze badges
asked Mar 8, 2018 at 16:21

3 Answers 3

3

Nero Phung answer was a good try, and led me to the real problem, looking for all sales_order_view appearances in the vendor folder

2.2 version adds Temando_Shipping module, which overrides sales_order_view layout

vendor/temando/module-shipping-m2/view/adminhtml/layout/sales_order_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
 <referenceContainer name="order_tab_info">
 <block class="Temando\Shipping\Block\Adminhtml\Sales\Order\View\Info" name="order_info" template="Temando_Shipping::sales/order/view/info.phtml">
 <container name="extra_customer_info"/>
 </block>
 </referenceContainer>
 </body>
</page>

So I could recover our custom block (using same XML layout as the one we used in 2.1.*) just by adding a module dependency

<module name="Vendor_Module">
 <sequence>
 <module name="Temando_Shipping"/>
 </sequence>
</module>
Andhi Irawan
9821 gold badge14 silver badges28 bronze badges
answered Mar 12, 2018 at 11:02
2
  • 1
    Congratulations! Commented Mar 12, 2018 at 16:39
  • 1
    Great work Raul, this saved me a lot of time debugging the same issue in our module on 2.2. Commented Apr 20, 2018 at 16:57
2
+100

As I can see. Magento has added a new container inside block named order_info:

<block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="Magento_Sales::order/view/info.phtml">
 <container name="extra_customer_info"/>
</block>

So you can try to use this code below:

<referenceContainer name="extra_customer_info">
 <block class="Vendor\Module\Block\Adminhtml\Sales\Order\View\Form" name="our_unique_block_name" template="Vendor_Module::our_template.phtml"/>
</referenceContainer>

Hope it will help!

Louis B.
1,1331 gold badge11 silver badges37 bronze badges
answered Mar 12, 2018 at 2:36
2
  • I have noticed that layout change in 2.2, but I wasn't sure it should affect... anyways, I have tried changing to <referenceContainer name="extra_customer_info"> but block still doesn't appear Commented Mar 12, 2018 at 10:39
  • magento.stackexchange.com/a/216961/3566 Commented Mar 12, 2018 at 11:12
0

Can you try with referenceContainer?

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
 <referenceContainer name="order_info">
 <block class="Vendor\Module\Block\Adminhtml\Sales\Order\View\Form" name="our_unique_block_name" template="Vendor_Module::our_template.phtml"/>
 </referenceBlock>
 </body>
</page> 
answered Mar 11, 2018 at 20:07
3
  • What's the purpose of the change? Why using referenceContainer to reference a block? Commented Mar 12, 2018 at 10:36
  • I use referenceBlock to modify block class (eg change template) and referenceContainer to include over blocks. And it work's Commented Mar 12, 2018 at 15:16
  • But... I believe you cannot reference a block (using its name) with a referenceContainer instruction Commented Mar 12, 2018 at 16:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.