-1

I am looking for is the subscription newsletter section. As you can see, there is only one success email template. I need to send 2 emails. Do you know which files handling the email section so I can customize....Your answer will be greatly appreciated.

enter image description here

marked as duplicate by Rajeev K Tomy, MTM, Marius, Anna Völkl, Amasty Sep 12 '14 at 7:21

This question was marked as an exact duplicate of an existing question.

  • Are you asking how to customise admin to add a setting for a second email template or how to customise the email sending process to send a second email (or both)? – Jonathan Hussey Sep 11 '14 at 7:31
  • Hi Jonathan, sorry for the confusion. The first one - adding a setting for a second email template. Any ideas? Appreciate your help – chris_magento Sep 11 '14 at 7:52
1

Assuming you are already familiar with module development, it's pretty straightforward to add extra settings under the system -> configuration section of admin, and to extend/edit settings added by core modules you just need to add the equivalent node structure into the system.xml file of your own module. Because your module will always load after all core modules the settings you define will take precedence.

In this case if you search the codebase, you will see the above settings are added by the newsletter core module system.xml at app/code/core/Mage/Newsletter/etc/system.xml:

<?xml version="1.0"?>
<config>
    <sections>
        <newsletter translate="label" module="newsletter">
            ...
            <groups>
                <subscription translate="label">
                    ...
                    <fields>
                        ...
                        <success_email_template translate="label">
                            <label>Success Email Template</label>
                            <frontend_type>select</frontend_type
                            <source_model>adminhtml/system_config_source_email_template</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </success_email_template>
                        ...
                    </fields>
                </subscription>
            </groups>
        </newsletter>
    </sections>
</config>

To extend this and add your own additional email template just mirror the same structure in your system.xml adding an additional dropdown setting:

<?xml version="1.0"?>
<config>
    <sections>
        <newsletter>
            <groups>
                <subscription>
                    <fields>
                        <another_success_email_template translate="label">
                            <label>Another Success Email Template</label>
                            <frontend_type>select</frontend_type
                            <source_model>adminhtml/system_config_source_email_template</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </another_success_email_template>
                    </fields>
                </subscription>
            </groups>
        </newsletter>
    </sections>
</config>

You will then be able to pull the setting you select here with:

$template = Mage::getStoreConfig('newsletter/subscription/another_success_email_template');

The only thing to note here is that it appears the sort order of the settings is set to 1 for every setting in the core system.xml so you might have trouble getting the order set correctly for your new setting, however you could redefine the sort order for the existing settings if you wanted also in your new system.xml file.

<?xml version="1.0"?>
<config>
    <sections>
        <newsletter>
            <groups>
                <subscription>
                    <fields>
                        <success_email_template>
                            <sort_order>1</sort_order>
                        </success_email_template>
                        <another_success_email_template translate="label">
                            <label>Another Success Email Template</label>
                            <frontend_type>select</frontend_type
                            <source_model>adminhtml/system_config_source_email_template</source_model>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </another_success_email_template>
                            <sort_order>3</sort_order>
                        </un_email_identity>
                        ...
                    </fields>
                </subscription>
            </groups>
        </newsletter>
    </sections>
</config>
  • Hi Jonathan! Let me try the if the code is working. thank you sooo much! ..Please don't go, hope you will be here in case im stuck.... – chris_magento Sep 11 '14 at 9:07
  • Hi Jonathan, mind to share which file is pointing to this $template = Mage::getStoreConfig('newsletter/subscription/another_success_email_template'); – chris_magento Sep 12 '14 at 1:36
  • That's the line you need to use in order to pull the extra template setting - use it wherever you are sending the extra success email to define the template to use. Have a look at my answer here for a very quick run through of sending transactional emails. – Jonathan Hussey Sep 12 '14 at 5:29
  • @JonathanHussey : this is also a good solution. But rather than this my approach would be more correct. What's your thought on that ? +1 for this answer – Rajeev K Tomy Sep 12 '14 at 5:47
  • I'm guessing you meant to insert a link with your comment? – Jonathan Hussey Sep 12 '14 at 5:50

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