Reputation: 1150
I'm currently in the process of finalizing a custom controller to accept Ajax request for a quote form. I have been able to successfully set up everything, and it is sending properly. The question I have is relating to the method of linking a Transactional e-mail template from the CMS to the controller I have set up.
I have a template in the locale of the Magento install, and have been able to load it into the Transactional email manager of the backend. How would I be able to get the id of that template and load it into the mail object? I have attempted using the simple numerical id, and that doesn't seem to be working.
Config.xml
<global>
<template>
<email>
<custom_quote>
<label>Custom Quote Form</label>
<file>custom-quote.html</file>
<type>html</type>
</custom_quote>
<trade_printer>
<label>Trade Printer Form</label>
<file>trade-printer.html</file>
<type>html</type>
</trade_printer>
</email>
</template>
</global>
Upvotes: 1
Views: 598
Reputation: 1150
After reading up on the available methods, I discovered that
loadDefault()
will always load the template from the locale codebase. Utilizing loadByCode()
with the name specified in the Transactional Email editor will load the customized template.
Final Code
$emailTemplate = Mage::getModel('core/email_template')->loadByCode('Template Name Here');
Upvotes: 1
Reputation: 2762
this is a sample code for sending email with email template
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('custom_quote');
$emailTemplateVariables = array();
$emailTemplateVariables['myvar1'] = 'Branko';
$emailTemplateVariables['myvar2'] = 'Ajzele';
$emailTemplateVariables['myvar3'] = 'ActiveCodeline';
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->send('[email protected]','John Doe', $emailTemplateVariables,$storeId=null);
Upvotes: 1