Magento Programming Loading Processed Email Templates

In Magento you may need to process the email text for an email but sometimes those templates are default ones, other times they can be a customized one set in the admin settings area. A customized email template from system > transactional emails menu will set in your core_config_data a numeric value for the customized email template.  There are 2 methods that load email templates one is for if the template is numeric (customized) other for if it’s just a default one from the config.

To Properly load in either case, you can use the code below:

// large array of email variables, just one here for example
$firstname = 'Joe';
$emailTemplateVariables = array('firstname'=>$firstname);
$emailTemplate = Mage::getModel('core/email_template');
// config is the config path to the email template, here is for the new order as example
$emailTemplateId = Mage::getStoreConfig('sales_email/order/template');
if (is_numeric($emailTemplateId)) {
} else {
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);



Get The Latest Rental Business Tips and Updates!

Special Offers, Product Updates, Insider Business Tips, sign up today to the Sales Igniter Email List!


Please signup with your email and we'll send you the files 

We'll send you a few follow up emails with great Rental Business Tips, Special Offers, ways to increase sales, and more.

No thanks, I'll pass