Skip to content

Instantly share code, notes, and snippets.

@dupadhyay3
Created April 23, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dupadhyay3/cb60da99213156930189e80fc879e682 to your computer and use it in GitHub Desktop.
Save dupadhyay3/cb60da99213156930189e80fc879e682 to your computer and use it in GitHub Desktop.
Magento 1 Order Email Template Preview
<?php
require_once 'app/Mage.php';
Mage::app();
ini_set('display_errors', 1);
// loads the proper email template
$emailTemplate = Mage::getModel('core/email_template')
->load(7);
// All variables your error log tells you that are missing can be placed like this:
$emailTemplateVars = array();
$emailTemplateVars['order'] = Mage::getModel('sales/order')->load(14513);
$order = $emailTemplateVars['order'];
$emailTemplateVars['usermessage'] = "blub";
$emailTemplateVars['store'] = Mage::app()->getStore();
$emailTemplateVars['sendername'] = 'noissue';
$emailTemplateVars['receivername'] = $order->getCustomerName();
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore(Mage::app()->getStore());
$emailTemplateVars['payment_html'] = $paymentBlock->toHtml();
//displays the rendered email template
echo $emailTemplate->getProcessedTemplate($emailTemplateVars);
@dupadhyay3
Copy link
Author

Add this file into magento root folder
Replace order id and email template id with your id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment