如何在Magento 的email模板中获取当前时间?
{{var dateAndTime}} 无效. 我需要在邮件发送时获取当前时间。
你可以重写发送邮件的方法,增加一个当前时间的参数。比如:你想在订单邮件里显示当前时间,那么你得重写方法Mage_Sales_Model_Order::sendNewOrderEmail
方法。
原方法:
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
);
改成:
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'dateAndTime' => Mage::getModel('core/date')->date('Y-m-d H:i:s'), //change format as needed.
)
);
然后使用{{var dateAndTime}} 在你调用的模板里。