7

I'm following https://ranasohel.me/2015/10/02/how-to-overwrite-sales-view-order-phtml-file-in-magento2/

I would like to override magento\vendor\magento\module-shipping\view\adminhtml\templates\order\view\info.phtml

How to do this?

3

One of the easiest way is that we will create a new backend admin: How to enable custom admin theme in Magento 2.

app/design/adminhtml/{Vendor}/{Theme}/Magento_Shipping/templates/order/view/info.phtml

The second way, set our custom template

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

<referenceBlock name='order_info'>
  <arguments>
    <argument name='template' xsi:type='string'>Vendor_Module::order/view/info.phtml</argument>
  </arguments>
</referenceBlock>

Load custom module layout after shipping

app/code/{Vendor}/{Module}/etc/module.xml

<sequence>
        <module name="Magento_Sales"/>
</sequence>
  • Does is need to create new theme for this? Can't we override with Magento Default Backend Theme? – Ankit Shah Nov 30 '16 at 2:39
  • It depends on your need. If you don't need to create a custom theme, we can choose the second. – Khoa TruongDinh Nov 30 '16 at 2:41
  • 1
    Ok I'm using Second Way. sales_order_view.xml is <?xml version="1.0"?> <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> <referenceBlock name="order_info"> <action method="setTemplate"> <argument name="template" xsi:type="string">Custom_Module::order/view/info.phtml</argument> </action> </referenceBlock> </body> </page> Where to put sequence code? – Ankit Shah Nov 30 '16 at 2:43
  • In etc/module.xml – Khoa TruongDinh Nov 30 '16 at 2:45
  • So my module.xml will be <?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.1"> <sequence> <module name="Magento_Shipping"/> </sequence> </module> </config> – Ankit Shah Nov 30 '16 at 3:07
3

I've faced the same issue if i refrence to order_info block, you need to reference to order_shipping_view block instead

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_shipping_view">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Namespace_Module::order/view/info.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

app/code/Namespace/Module/view/adminhtml/templates/order/view/info.phtml

<h1> Override Success </h1>
<h2> Put Your desire content here </h2>

flush magento cache, do setup:upgrade

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.