I am working on modifying email templates. {themeName}/template/email/order/items/order/default.phtml

The above template triggers when the user (guest or customer) has placed the order.

In the above template, there are some variables like:

$_item = $this->getItem();
$_order = $this->getItem()->getOrder(); 

if I use any debugging methods like Mage::log or zend_debug::dump, the checkout page is hanging up and the order is never being processed.

So, my question is what should I use to debug email templates here?

I also used echo which is always showing an empty string or array for an array holding variable.

  • Can someone please atleast tell me how to get order_id from the above variables?
    – Mr_Green
    Commented Apr 17, 2014 at 5:35
  • Have you tried to use Mage::log in the block class (Mage_Sales_Block_Order_Email_Items_Order_Default)?
    – nevvermind
    Commented Apr 17, 2014 at 10:43
  • @nevvermind I tried Mage::log in Mage_Sales_Block_Items_Abstract. which has the same issue as I mentioned above in my post. I didn't get relation to your mentioned class.
    – Mr_Green
    Commented Apr 17, 2014 at 10:47
  • The email tpl is in app/locale/en_US/template/email/sales/order_new_guest.html (for guest). There, a layout handle is inserted - sales_email_order_items. This handle is declared in app/design/frontend/base/default/layout/sales.xml. The template you're having problems with has the block set to sales/order_email_items_order_default - aka Mage_Sales_Block_Order_Email_Items_Order_Default.
    – nevvermind
    Commented Apr 17, 2014 at 10:53
  • @nevvermind Thanks for the info. Actually, I am getting the products html to the email from {themeName}/template/email/order/items/order/default.phtml (I checked it thoroughly) The other part of email like "Thank you for purchasing.. blah blah blah" is coming from what you have mentioned above (I didn't check but I think so). To be frank, I solved this problem but my question is how to debug in these email templates?
    – Mr_Green
    Commented Apr 17, 2014 at 10:58

2 Answers 2


On the hackathon we (read as they :-)) implemented a module to preview mail templates: https://github.com/magento-hackathon/E-MailPreview

Maybe this helps.


You could also try Mage::log($your_object->debug()); this will hopefully give you the information that you need.

It will show you all the objects data as an array of key => value and will show you the class of any sub-data that is an object.

if (is_scalar($value)) {
    $debug[$key] = $value;
} elseif (is_array($value)) {
    $debug[$key] = $this->debug($value, $objects);
} elseif ($value instanceof Varien_Object) {
    $debug[$key.' ('.get_class($value).')'] = $value->debug(null, $objects);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.