2

I've loaded New Order transactional email to insert a custom block. I inserted it under the order items table layout handle call, and try to pass it $order variable.

{{layout handle="sales_email_order_items" order=$order}}
...
{{block type="mymodule/sales_order_email_description" order=$order}}

In Mymodule_Block_Sales_Order_Email_Description class I wrote:

protected function _construct() {        
    $this->setTemplate('email/order/description.phtml');
}

And finally in description.phtml I try to access order:

$order = $this->getOrder();
...
$order->getId()

At this point, exception rise: Fatal error: Call to a member function getId() on a non-object ... ...

I followed several tutorials, like this magento email templates but I'm still stuck with this fatal error.

Any ideas?

Nijin Narayanan
  • 2,269
  • 2
  • 27
  • 46
trodriguez
  • 75
  • 1
  • 7

2 Answers2

0

Let's take a look;

You can define the block with a template, the construct isn't needed any more. {{block type="mymodule/sales_order_email_description" template="email/order/description.phtml" order=$order}}

Indeed you could get the parameter values with $this->getOrder(). But $order->getId() may not work, $order->getEntityId(). Maybe you could try a var_dump to see if there is any order data.

Jeffrey de Graaf
  • 479
  • 3
  • 17
-1

Try this in your .phtml file:

$order = $this->getData('order');

As described here: http://www.webspeaks.in/2011/06/customize-new-order-email-template-in-magento.html

Dewayne
  • 3,682
  • 3
  • 25
  • 23