Reputation: 570
I am creating a template for abandoned orders.
But when I try to use the template created, the send a blank email, more the template appears in: System/Transactional Email
Template
The temaplate is a copy of order_update.html
with name test_order_update.html
in en_US/template/email/sales/
Config.xml - This is working
<global>
<template>
<email>
<custom_template module="mymodule">
<label>Abandoned Transactions</label>
<file>sales/test_order_update.html</file>
<type>html</type>
</custom_template>
</email>
</template>
</global>
Shooting - Do not load the template
<?php
$storeId = Mage::app()->getStore()->getId();
$emailTemplate = Mage::getModel('core/email_template');
$emailTemplate->loadDefault('test_order_update');
$emailTemplate->setTemplateSubject('my subject here');
$email = Mage::getStoreConfig('trans_email/ident_sales/email');
$name = Mage::getStoreConfig('trans_email/ident_sales/name');
$emailTemplate->setSenderName($name, $storeId);
$emailTemplate->setSenderEmail($email, $storeId);
$emailTemplateVariables['username'] = ' something';
$emailTemplateVariables['store_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
$emailTemplate->send('[email protected]', 'name...', $emailTemplateVariables);
?>
Email received
Sender: Sales <[email protected]>
Subject: my subject here
Content:
Upvotes: 0
Views: 186
Reputation: 166
try replacing
$emailTemplate->loadDefault('test_order_update');
with
$emailTemplate->loadDefault('custom_template');
because to load a email template you have to give the tag name that you provide in the config.xml
also add following line before sending mail
$emailTemplate->getProcessedTemplate($emailTemplateVariables);
if your template is copy of order_update.html you also need to pass the order object as teh email parameter.
Upvotes: 3