2

I want to override the template file for backend Order view

I've checked template path and found that this file is called.

vendor/temando/module-shipping-m2/view/adminhtml/templates/sales/order/view/info.phtml

So to override I did following in my module

Vendor/Module/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"></module>
     <sequence>
            <module name="Magento_Wishlist"/>
            <module name="Temando_Shipping"/>
     </sequence>
</config>

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>
    <referenceContainer name="left">
        <referenceBlock name="order_info">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_Module::info.phtml</argument>
            </action>
        </referenceBlock>
    </referenceContainer>
</body>
</page>

And I've put info.phtml in the following path app/code/Vendor/Module/view/adminhtml/templates/info.phtml

But still, it's not working, clear cache and all but still not taking above file.

What can be wrong?

0

I've repeated your steps and the override works for me.

Here's what i did:

Added app/code/Vendor/Module/view/adminhtml/layout/sales_order_view.xml to an existing module

<?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="left">
            <referenceBlock name="order_info">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Vendor_Module::info.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

Copied the contents of vendor/magento/module-sales/view/adminhtml/templates/order/view/info.phtml into a new template app/code/Vendor/Module/view/adminhtml/templates/info.phtml:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var \Magento\Sales\Block\Adminhtml\Order\View\Info $block
 */

// @codingStandardsIgnoreFile

$order = $block->getOrder();

$orderAdminDate = $block->formatDate(
    $block->getOrderAdminDate($order->getCreatedAt()),
    \IntlDateFormatter::MEDIUM,
    true
);

$orderStoreDate = $block->formatDate(
    $order->getCreatedAt(),
    \IntlDateFormatter::MEDIUM,
    true,
    $block->getTimezoneForStore($order->getStore())
);
?>

<!-- I added this bit -->
<h1>OVERRIDE</h1>
<h1>OVERRIDE</h1>
<h1>OVERRIDE</h1>

<section class="admin__page-section order-view-account-information">
    <div class="admin__page-section-title">
        <span class="title"><?= $block->escapeHtml(__('Order & Account Information')) ?></span>
    </div>

Ran the setup:upgrade command to clear all caches:

$ php -f bin/magento setup:upgrade

Visited an order details page in the admin: http://www.example.test/admin/sales/order/view/order_id/18/key/29acbf64d18925d298b839dae9c432d2090ec92b3b175649bf3a98c69fae6b47/

enter image description here

It would appear that the problem therefore lies with the Temando extension. I would check to see if the above steps work after disabling the Temando extension.

If so, I would get in contact with Temando.

  • Yeah it seems the problem with Temando extension – Kaushal Suthar Jun 15 '18 at 12:46
0

I did a very silly typo mistake.

In etc.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"></module>
     <sequence>
            <module name="Magento_Wishlist"/>
            <module name="Temando_Shipping"/>
     </sequence>
</config>

It should be like following

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Hs_Helper" setup_version="1.0.0">
        <sequence>
                <module name="Temando_Shipping"/>
                <module name="Magento_Wishlist"/>
        </sequence>
    </module>
</config>

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.