I would like to know if it's possible to get code html of transactional emails before send email to user with template variables etc...
I override _sendEmailTemplate and I try to get HTML code in this way:
protected function _sendEmailTemplate($template, $sender, $templateParams = array(), $storeId = null) {
/** @var $mailer Mage_Core_Model_Email_Template_Mailer */
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($this->getEmail(), $this->getName());
$mailer->addEmailInfo($emailInfo);
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig($sender, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId(Mage::getStoreConfig($template, $storeId));
$mailer->setTemplateParams($templateParams);
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($template); // I try to get template
$processedTemplate = $emailTemplate->getProcessedTemplate($templateParams); //set template variables and get html code
print_R($processedTemplate);
exit;
$mailer->send();
return $this;
}
Comments in code.
It doesn't work. Any ideas will be appreciated
app/code/core/Mage/Core/Model/Email/Template.php
Check send function there you can echo html of email and you can save it