Magento 1.9 – How to Get Email Template Name in System Configuration

email-templatesmagento-1.9

In module i have a custom email template.

my code in config.xml

<template>
            <email>
                <general_notification translate="label" module="example">
                    <label>Notifications</label>
                    <file>notification.html</file>
                    <type>html</type>
                </general_notification>

            </email>
        </template>

Using this code i will get template name in system config

system.xml

    <notification>
    <label>Notification send to admin and customer</label>
        <frontend_type>select</frontend_type>


        <source_model>example/email_notification</source_model>
            <sort_order>90</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>

    </notification>

In model

class NameSpace_Example_Model_Email_Notification
{
    protected $_options;

    public function toOptionArray(){
        return array(
            array('value' => '', 'label'=>Mage::helper('example')->__('Do not send')),
            array('value' => 'general_notification', 'label'=>Mage::helper('example')->__('New Notification(default template from locale)')),
        );
    }
}

Now In System > Transaction Email I m add New template and save that template So now i want this Email template name in system configuration how to get that please help me

Best Answer

Once you created email template you can get with below default code of magento source model

    <notification>
                <label>Select Email Template </label>
                <comment>It is advisable to create a new email template for this purpose and then select it in this configuration. Make sure you add review URL in your template. For e.g., {{ReviewURL}} <![CDATA[ <br /><span style="color:#FFA500">NOTE:- Default template from locale should not be used. Make sure you add product Name in your template. For e.g., {{ProductName}} You can also use other variables like OrderNumber {{OrderNumber}}</span>]]></comment>
                <frontend_type>select</frontend_type>
                <backend_model>mcautoreviewreminderemail/Mcautoreviewreminderemailtemplate</backend_model>
                <source_model>adminhtml/system_config_source_email_template</source_model>
                <sort_order>4</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <can_be_empty>1</can_be_empty>
   <notification>

i am sure it will work for you.

Related Topic