overriding template in magento 2

overriding template in magento 2

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
overriding template in magento 2

Overriding Email Templates in Magento 2: A Step-by-Step Guide for Non-Devs

As a newbie to Magento, you might find yourself needing to customize email templates created by third-party extensions like Amitshree. While the learning curve can be steep, I’ll guide you through this process step by step.

Understanding the Template Structure in Magento 2

In Magento 2, all email templates are located under vendor/magento/module-email/view/frontend/templates. Third-party extensions typically store their custom templates within their own modules.

For Amitshree’s extensions, you can usually find them under something like app/code/Amitshree/ModuleName/view/frontend/templates.

Step 1: Locate the Template to Override

First, identify the exact template file you want to override. Let me assume it’s located at this path for now:

app/code/Amitshree/YourExtension/view/frontend/templates/email/sales/order_new.html

Step 2: Create a New File Structure

To override this template, you need to create a new directory structure in your theme.

  1. Navigate to app/design/frontend/yourVendor/yourTheme/.
  2. Inside the Magento_Email folder (if it doesn’t exist, create it).
  3. Inside Magento_Email, create another folder called templates.
  4. Inside templates, create a folder named email.
  5. Finally, inside email, create a folder for the specific template type you’re overriding. In your case, that would be sales.

So now you’ve created this structure:

app/design/frontend/yourVendor/yourTheme/Magento_Email/templates/email/sales/

Step 3: Copy and Override the Template

Now let’s copy Amitshree’s template into your new folder.

  1. Open the terminal on your machine.
  2. Navigate to app/code using the command line (you can use a tool like Git Bash or Terminal on Mac).
  3. Use the following command to copy the file from Amitshree’s module:
cp -R app/code/Amitshree/YourExtension/view/frontend/templates/email/sales/order_new.html app/design/frontend/yourVendor/yourTheme/Magento_Email/templates/email/sales/

Step 4: Make Your Changes

Open the copied file in your preferred text editor or IDE (I recommend PhpStorm).

You can now start customizing the HTML, adding new blocks of content, modifying existing ones, etc. Remember to follow proper XHTML/HTML5 standards.

Step 5: Check and Test Your Template

Once you’ve made all your changes:

  1. Save the file.

  2. Clear your Magento cache using the command line:

    php bin/magento cache:clean
    
  3. Now, trigger an order new email in your backend to see if your override is working correctly.

Conclusion and Further Reading

Overriding templates in Magento 2 can be a bit complex at first, but with practice, it becomes second nature. The key is understanding the directory structure and how Magento uses the theme hierarchy for template resolution.

If you’re looking to learn more about Magento development best practices, I recommend checking out Laravel Company’s Magento resources. They have excellent guides on customizing layouts and using XML layout files, which work hand in hand with the template overrides you’ve just learned.

Happy coding! Let me know if you need any further assistance.

Magento 2 Extensions Themes Email

Our network