1

I want to override a Magento 2 email in adminhtml, has anyone done this already and what is the correct way to do this?

I have tried it like this: app/design/{vendor}/{theme}/{module}/email

Thank you!

3
  • Which email template you need to override? Jun 26, 2017 at 13:33
  • A custom module's adminhtml email file Jun 27, 2017 at 7:04
  • Add your custom module path. Jun 27, 2017 at 7:05

3 Answers 3

2

Found it out myself!

1) I have created a custom module:

app/code/Vendor/Module/registration.php

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_Module',
    __DIR__
);

app/code/Vendor/Module/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Theme\Model\View\Design">
        <arguments>
            <argument name="themes" xsi:type="array">
                <item name="frontend" xsi:type="string">Magento/luma</item>
                <item name="adminhtml" xsi:type="string">Vendor/backend</item>
            </argument>
        </arguments>
    </type>
</config>

app/code/Vendor/Module/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Backend"/>
        </sequence>
    </module>
</config>

2) in CLI use php -d memory_limit=-1 bin/magento setup:upgrade

3) After creating the module itself i have created the adminhtml folder:

app/design/adminhtml/Vendor/backend/registration.php

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'adminhtml/Vendor/backend',
    __DIR__
);

app/design/adminhtml/Vendor/backend/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Vendor backend Theme</title>
    <parent>Magento/backend</parent>
</theme>

4) And in the custom adminhtml folder you can now rewrite anything, i made a rewrite for the following file like this:

app/design/adminhtml/Vendor/backend/Module_Name/email/tracking.html
-1

There a way to customize an email template, that is using Magento Admin - Email Templates

You can refer to this link: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/templates/template-email.html#customize-email-admin

1
  • Hi Walish Le, thank you for your response, i am aware of the way of editing like that. But i want to override the file, so that it wont be in the system but in the file structure. Jun 26, 2017 at 11:33
-1

See my below example for override email template

For Example if you want to override customer new account email template

Copy email template from

vendor/magento/module-customer/view/frontend/email/account_new.html

to

/app/design/frontend/Vendor/YourTheme/Magento_Customer/email/account_new.html

1
  • Hi S H Patel, thanks for your response but this is for overriding frontend templates, not adminhtml templates right? Jun 27, 2017 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.