简体   繁体   中英

magento - Add more options to Email Template dropdown list

I created a module, and I want to add some of my custom email template as option for the Email Template dropdown, say, "Create New Account" in Admin > System > Configuration > Customers > Customer Configuration .

I tried to add a node in my custom module, like

<global>
    <template>
        <email>
            <customer_account_create_template>
                ...
            </customer_account_create_template>
        </email>
    </template>
</global>

PLEASE NOTE THAT I don't have my code when I wrote this, so customer_account_create_template might be incorrect, but I successfully REPLACED the option with my custom template.

The point is, I wanted to add it as another option, NOT to replace the default one. So, do you have any idea?

Add at config.xml you should have your template declared inside the global tag and have a label on it.

<global>
    <template>
        <email>
            <custom_email_template translate="label" module="yourcustommodule">
                <label>Custom Email Template</label><!-- this should be shown in the config dropdown-->
                <file>mymodule/custom_email.html</file>
                <type>html</type>
            </custom_email_template>
        </email>
    </template>
</global>

system.xml field must match the name of the template with _ instead of / . In your case custom_email_template.

So your system.xml should look like this:

<sections>
    <custom ...>
       <groups>
           <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>
              </template>
           </email>
       </groups>
    </custom>
</sections>

And the <default> tag in config.xml should be

  <default>
        <custom>
          <email>
              <template1>custom_email_template1</template1>
              <template2>custom_email_template2</template2>
          </email>
        </custom> 
    </default>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM