Magento: Test order email with filled variables

20. Februar 2015 at 10:13

magento ecommerce logo

If you would edit order emails you can use the following code to check the order emails with filled variables with order data:

require_once 'app/Mage.php';
// loads the proper email template
$emailTemplate  = Mage::getModel('core/email_template')
$templateId = "Neue Bestellung (Template)";
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);
// All variables your error log tells you that are missing can be placed like this:
$emailTemplateVars = array();
$emailTemplateVars['usermessage'] = "test message";
$emailTemplateVars['store'] = Mage::app()->getStore();
$emailTemplateVars['sendername'] = 'sender name';
$emailTemplateVars['receivername'] = 'receiver name';
// order you want to load by ID
$emailTemplateVars['order'] = Mage::getModel('sales/order')->load(673);
// load payment details:
// usually rendered by this template:
// web/app/design/frontend/base/default/template/payment/info/default.phtml
$paymentBlock = Mage::helper('payment')->getInfoBlock($emailTemplateVars['order']->getPayment())
$emailTemplateVars['payment_html'] = $paymentBlock->toHtml();
//displays the rendered email template
echo $emailTemplate->getProcessedTemplate($emailTemplateVars);
// you can send this email template
$receiveName = 'Daniel Briegert';
$receiveEmail = '';
//$emailTemplate->send($receiveEmail,$receiveName, $vars);


Please share this article von facebook & google plus or where you want, thank you!

GD Star Rating
GD Star Rating
Magento: Test order email with filled variables, 10.0 out of 10 based on 2 ratings