0

What is the best way to override below template file in module ?

Magento_Sales::email/items/creditmemo/default.phtml
1

You can create below XML file in your custom module here..

app/code/VendorName/ModuleName/view/frontend/layout/sales_email_order_creditmemo_renderers.xml

Content for this file..

<?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.email.order.creditmemo.renderers.default">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">VendorName_ModuleName::order/creditmemo/items/renderer/default.phtml</argument>
            </action>
        </referenceBlock>
        <referenceBlock name="sales.order.print.creditmemo.renderers.grouped">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">VendorName_ModuleName::order/creditmemo/items/renderer/default.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

And you can add your phtml file here..

app/code/VendorName/ModuleName/view/frontend/templates/order/creditmemo/items/renderer/default.phtml

After changing this, flush Magento cache once.

That's it. Hope this will work for you!

2
  • 1
    Thanks for the answer. let me check – devhs Mar 4 at 10:05
  • 1
    Thanks it seems to be working. – devhs Mar 4 at 10:32

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.