Search code examples
magentoemailmagento-1.7system-configuration

Getting custom email template in system configuration magento?


I need to get custom email template in admin system configuration.

system.xml

This is my email template field code.

<email_template>
    <label>Email Template</label>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <sort_order>5</sort_order>
    <frontend_type>select</frontend_type>
    <source_model>adminhtml/system_config_source_email_template</source_model>
</email_template>

config.xml

<template>
    <email>
    <custom_email_template translate="label" module="mymodule">
    <label>Custom Email Template</label>
    <file>mymodule/custom_email.html</file>
    <type>html</type>
    </custom_email_template>
    </email>
</template>
<default>
    <mymodulesettings>
      <email>
          <email_template>custom_email_template</email_template>
      </email>
    </mymodulesettings>
</default>

And i have added email.html file in locale/en_US/template/email/mymodule/ path Now i got a outut like this enter image description here

But i need to show my custom email name in that dropdown. like:enter image description here


Solution

  • I have find the solution i made a mistake in my config.xml file.

    We have to define the mail template like this

    <template>
        <email>
            <{section_name}_{group_name}_{fields_name} translate="label" module="mymodule">
            <label>Custom Email Template</label>
            <file>mymodule/custom_email.html</file>
            <type>html</type>
            </{section_name}_{group_name}_{fields_name}>
        </email>
    </template>
    

    {section_name} {group_name} {fields_name} in system.xml file.

    Cheers