0

Has someone an idea on how to override this template?

I have tried the following without any success:

In app/code/Custom/Shipping/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'adminhtml/Custom/Shipping',
    __DIR__
);

In app/code/Custom/Shipping/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Custom_Shipping" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Shipping"/>
        </sequence>
    </module>
</config>

In app/code/Custom/Shipping/view/adminhtml/layout/sales_order_invoice_new.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="form">
            <block class="Magento\Shipping\Block\Adminhtml\Order\Tracking\Invoice" name="tracking" template="Custom_Shipping::order/tracking.phtml"/>
        </referenceBlock>
    </body>
</page>

In app/code/Custom/Shipping/view/adminhtml/templates/order/tracking.phtml I'd adjust the code that comes originally from tracking.phtml in the vendor map

0

Try this

<?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="tracking">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Custom_Shipping::order/tracking.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>
| improve this answer | |
0

In your module file "app/code/Custom/Shipping/view/adminhtml/layout/sales_order_invoice_new.xml"

Please update code with following code.

<?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="form">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Custom_Shipping::order/tracking.phtml</argument>
        </action>
    </referenceBlock>
</body>

Clear cache and check, Hope it will work for you.

| improve this answer | |
  • This generates an error: Invalid argument supplied for foreach() at tracking.phtml:71; I think this has to do with the fact that the template cannot find the definition of getCarriers() which is defined in the block class Magento\Shipping\Block\Adminhtml\Order\Tracking – Julian Murillo Oct 22 '18 at 8:50
0

We cannot overwrite admin files directly. We have to either create a new module for this or use a existing once.

I think the following code may help you

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

Try clearing cache and reindexing. You can also refer to this link for more details. Magento2: How to override admin files

Hope it helps!

| improve this answer | |
  • This also generates an error: Invalid argument supplied for foreach() at tracking.phtml:71; I think this has to do with the fact that the template cannot find the definition of getCarriers() which is defined in the block class Magento\Shipping\Block\Adminhtml\Order\Tracking – Julian Murillo Oct 22 '18 at 8:50
0

It seems like you are trying to override template using your custom module.

If it is correct, then the code in registration.php needs to be changed.
According to your current code, you are registering a theme, whereas you should register a module as follows:

<?php

use Magento\Framework\Component\ComponentRegistrar;

    ComponentRegistrar::register(
        ComponentRegistrar::MODULE,
        'Custom_Shipping',
        __DIR__
    );
| improve this answer | |

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.