1

I have a custom module that needs to overwrite the new order email template, the location for the default email template is

vendor\magento\module-sales\view\frontendemail\order_new.html,

and this file get the data from

vendor\magento\module-sales\Model\Order\Email\Sender\OrderSender.php,

I need to override these two files from my custom module but I don't know how to do it

5
  • 1
    You can overrider email template using your custom theme Magento_Sales/email/order_new.html and block file using di.xml file Feb 8, 2017 at 7:20
  • @Rakesh how to do it in custom module?
    – simple guy
    Feb 8, 2017 at 7:24
  • 1
    for email template i dont know how to override using custom module. Feb 8, 2017 at 7:27
  • I found that the best way to do this is through an event observer. More details in the accepted answer here: magento.stackexchange.com/questions/159142/… Nov 8, 2017 at 16:58
  • @David, were you able to change the sales order email template by overriding in custom module? If so then please share the code snippet, I need to do the same but unable to achieve it
    – Shireen N
    Jul 18, 2018 at 9:47

3 Answers 3

0

Your override file path is incorrect.

You have to just override order_new.html file at below location.

app/design/frontend/[Vendor_Name]/[Theme_Name]/Magento_Sales/email/order_new.html

Clear & Flush the Cache by using below command:-

sudo php bin/magento cache:clean
sudo php bin/magento cache:flush
0

You can overwrite email templates in a module like this:

  1. Create Vendor/Module/etc/email_templates.xml

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
        <template id="sales_email_order_template" label="Vendor New Order" file="sales/order_new.html" type="html" module="Vendor_Module" area="frontend"/>
    </config>
    
  2. Put your template in Vendor/Module/view/frontend/email/sales/order_new.html

  3. Make sure that your module is loaded after original Magento_Sales module by adding dependency in Vendor/Module/etc/module.xml

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

Create the order_new.html file in your module, path:app/code/{VendorName}/{PackageName}/view/frontend/email/

And do your customization.

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.