Domanda

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.

È stato utile?

Soluzione

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!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top