2

我已加载新订单交易电子邮件以插入自定义块。我将它插入到订单项表布局句柄调用下,并尝试将其传递给$order变量。

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

在 Mymodule_Block_Sales_Order_Email_Description 类中我写道:

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

最后在 description.phtml 我尝试访问订单:

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

此时,异常上升: Fatal error: Call to a member function getId() on a non-object ... ...

我遵循了几个教程,比如这个magento 电子邮件模板,但我仍然遇到这个致命错误。

有任何想法吗?

4

2 回答 2

0

让我们来看看;

您可以使用模板定义块,不再需要构造。 {{block type="mymodule/sales_order_email_description" template="email/order/description.phtml" order=$order}}

实际上,您可以使用$this->getOrder(). 但$order->getId()可能行不通,$order->getEntityId(). 也许您可以尝试使用 var_dump 来查看是否有任何订单数据。

于 2014-12-11T09:05:12.187 回答
-1

在你的 .phtml 文件中试试这个:

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

如此处所述:http ://www.webspeaks.in/2011/06/customize-new-order-email-template-in-magento.html

于 2016-09-05T15:59:11.750 回答