1

I'm using Magento 2.2.4 & want to override admin theme template file & the path of the file is here:-

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

Actually, I've to add an anchor link in this file.

Solution 1:- Working Solution without completely override:-

Step1.1:- Modified file:-

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

 <?xml version="1.0"?>
    <!--
    /**
     * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
     */
    -->
    <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">

                <!-- Commented core code by me -->

                <!-- <block class="Temando\Shipping\Block\Adminhtml\Sales\Order\View\Info" name="order_info" template="Temando_Shipping::sales/order/view/info.phtml"> -->

                <!-- End of Commented core code by me -->

                <!-- Added my @custom code -->

                 <block class="Temando\Shipping\Block\Adminhtml\Sales\Order\View\Info" name="order_info" template="Test_Clientform::sales/order/view/info.phtml">

                 <!-- End of the Added my @custom code -->

                    <container name="extra_customer_info"/>

                </block>
            </referenceContainer>
        </body>
    </page>

Step1.2:- Added custom CSS file to design custom link in my custom module:-

app/code/Test/Clientform/view/adminhtml/layout/sales_order_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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">
    <update handle="sales_order_transactions_grid_block"/>
    <head>
        <css src="Test_Orderdform::css/css.css"/>
    </head>
</page>

Step1.3:-Template file in my custom module:-

copied

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

content to

app/code/Test/Clientform/view/adminhtml/templates/sales/order/view/info.phtml

& added my custom link in this file.

After doing this I'm getting my expected result.

Please visit here to see:-

http://nimb.ws/rFzDsZ

But this is not a standard way because I've directly modified in the file:-

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

Solution 2:- Solution by completely override but getting a problem:-

In the solution2 only I need to override:-

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

because i already modified phtml file in solution1.

Step2.1:-

app/code/Test/Clientform/view/adminhtml/layout/sales_order_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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">
    <update handle="sales_order_transactions_grid_block"/>
    <head>
        <css src="Test_Orderdform::css/css.css"/>
    </head>

      <body>
        <referenceBlock name="column_name">
            <block class="Temando\Shipping\Block\Adminhtml\Sales\Order\View\Info" name="sales_order_view_custom" template="Test_Clientform::sales/order/view/info.phtml" />
        </referenceBlock>
    </body>

</page>

I'm getting the following result which is not expected one:-

http://nimb.ws/Uhc8Ji

You can see designs are improper/broken.

Note:- I think there can be some problem in:-

<referenceBlock name="column_name"> 

i replaced "column_name" with "order_info" but it doesn't work.

so please let me know what I need to add/modify so that I can resolve this problem.

Thanks in advance.

1 Answer 1

0

I'm still getting my feel around the overrides and scopes in magento 2, but I have had to override temando before for bugs. In my case, I made a local copy to app/code and modified the file in place until Temando/magento fixed the bug properly at which point I removed my code and went back to the composer version. (be aware, temando's support is easy to work with if you're dealing with problems. Customizations maybe not)

With that said, whenever I need to override something elsewhere, I add a folder for it to my custom module directory e.g. app/code/OurCompany/custom/Temando_Shipping/

I usually modify the module.xml to include a reference to temando in the 'sequence' (to make sure Temando is loaded first and my override comes second) app/code/OurCompany/custom/etc/module.xml

<?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='OurCompany_Custom' setup_version='0.0.6'>
        <sequence>
            <module name='Temando_Shipping'/>
        </sequence>
    </module>
</config>

then build your override code in the directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.