0

I saw many such questions, but all answers are basically copies of the same solution with custom theme. Is it possible just to override core file

vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml

without creating a custom theme? If so, what exactly path should I create to put altered track.phtml to? My intention is to make collection of altered files that will not be overwritten during Magento or 3rd party theme automatic upgrade so I can easily keep all core functionality changes. And this will allows me to keep changes even if theme is switched to another one. Thank you.

1 Answer 1

0

You can override that file using different ways :

1. Override template and xml file in your custom module :

  • You can add this XML file in your custom module and you can change path like..

app/code/Vendor/Module/view/frontend/layout/sales_email_order_shipment_track.xml

Content for this file is :

<?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="sales.order.email.shipment.track">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vendor_Module::email/shipment/track.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>
  • After adding above xml file you need to create template file in your custom module here.

app/code/Vendor/Module/view/frontend/templates/email/shipment/track.phtml

2. Override template file in your custom theme :

  • You can copy track.phtml file here in your custom theme

app/design/frontend/Vendor/Theme/Magento_Sales/templates/email/shipment/track.phtml

  • After that you can change anything here based on your requirement.

Note : In all above cases, your file will not change when you update your Magento version.

Hope this will help you!

13
  • Is above solution works for you ? Oct 16, 2019 at 18:05
  • Hi Kishan. Thank you for the reply, but this way of adding new files to point to altered files seems to be not much useful for me. So, there is no easy way of just copying original phtml file to correct place where Magento2 looks for overrides?
    – Frenger
    Oct 16, 2019 at 18:28
  • Can you please give me more information related to your query ? @Frenger Oct 16, 2019 at 18:33
  • What exactly info do you need? Once again: I want to override core magento2 file located on the path specified in the question. I though it is possible just to copy that phtml to a path like app/design/frontend/ ... , but I don't know what are deeper levels of folders that I need to create to let Magento2 find this altered track.phtml file to use it instead of default one.
    – Frenger
    Oct 16, 2019 at 18:46
  • 1
    It is a magic! With this path it work now! Thank you!
    – Frenger
    Oct 19, 2019 at 17:24

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.