Magento adding a custom email template dropdown

Magento adding a custom email template dropdown

September 4, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento adding a custom email template dropdown

Solving Magento Custom Email Template Dropdown Issue

In this post, we’ll dive into a common challenge faced by Magento developers - adding a custom email template dropdown for a specific module. We’ll walk through the provided code snippets and identify the issue preventing the new template from being used.

The Current Setup: Email Templates in Magento

Let’s first understand how Magento handles email templates out-of-the-box:

  • Email templates are defined under app/design/frontend/base/default/template/email.
  • Each template has a corresponding XML configuration path in system.xml.
  • To send an email using a specific template, you need to specify the template ID.

Analyzing the Provided Code

The developer has correctly set up the necessary files and configurations:

  1. config.xml: The template is defined here with the file name adminhtmlext/coupon_code_template.html.
<global>
    <template>
        <email>
            <coupon_code_reminder_email_template translate="label" module="adminhtmlext">
                <label>Coupon Code Reminder</label>
                <file>adminhtmlext/coupon_code_template.html</file>
                <type>html</type>
            </coupon_code_reminder_email_template>
        </email>
    </template>
</global>
  1. system.xml: The config option is correctly defined as a select field that pulls data from the adminhtml/system_config_source_email_template source model.
<fields>
    <coupon_code_reminder_email_template translate="label">
        <label>Coupon Reminder Template</label>
        <frontend_type>select</frontend_type>
        <source_model>adminhtml/system_config_source_email_template</source_model>
        <sort_order>20</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
    </coupon_code_reminder_email_template>
</fields>
  1. install-0.1.0.php: The installer script correctly sets the default template value.

  2. EmailController.php: The controller is set up to send an email using the configured template ID.

$templateId = Mage::getStoreConfig(self::EMAIL_TEMPLATE_XML_PATH);

The Issue: Why the New Template Isn’t Being Used

The issue lies in how Magento retrieves and parses the email templates. Here are a few things to check:

  • Make sure the adminhtmlext/coupon_code_template.html file is located in the correct path (app/design/frontend/base/default/template/email/) with the proper permissions.
$installer->setConfigData('coupon_code/reminder/email_template', 'coupon_code_reminder_email_template');
  • Ensure that coupon_code_reminder_email_template is a valid email template in your Magento installation. You can verify this by checking the core_email_template table.

A Potential Solution: Registering Your Own Template

To ensure your custom template is properly registered, you may need to create an additional XML file under app/design/frontend/base/default/system/config.xml:

<config>
    <global>
        <templates>
            <adminhtmlext_email_template translate="label">
                <label>Coupon Code Reminder (Custom)</label>
                <file>coupon_code_template.html</file>
                <type>html</type>
            </adminhtmlext_email_template>
        </templates>
    </global>
</config>

Then, update your system.xml file to reference this new template:

<fields>
    <coupon_code_reminder_email_template translate="label">
        <!-- ... -->
        <source_model>adminhtml/system_config_source_email_template</source_model>
        <options>
            <option value="adminhtmlext_email_template">Coupon Code Reminder (Custom)</option>
        </options>
        <!-- ... -->
    </coupon_code_reminder_email_template>
</fields>

This approach ensures that your custom template is properly registered and available in the dropdown menu.

Conclusion: Understanding Magento’s Email Template System

In this post, we’ve examined a common scenario where developers struggle to add a custom email template dropdown for their modules. By understanding how Magento manages its email templates and verifying the correct setup of the necessary files and configurations, you can ensure that your custom templates are properly registered and used.

Remember to always check the documentation or consult with experienced Magento developers if you encounter any issues. For more in-depth guides on Magento development, be sure to visit Laravel Company.

Happy coding!

Extensions Themes Admin Configuration

Our network