2014-02-26 38 views
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 I類寫道:

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 ... ...

我跟隨severa l教程,像這樣magento email templates,但我仍然堅持這個致命的錯誤。

任何想法?

回答

0

讓我們來看看;

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

的確,您可以通過$this->getOrder()獲取參數值。但$order->getId()可能不起作用,$order->getEntityId()。 也許你可以嘗試var_dump來查看是否有任何訂單數據。

相關問題