Magento 电子邮件模板:阻止不从 adminhtml 呈现
我担心我已经进入了未知的 Magento 领域。我已经用尽了我仅存的谷歌搜索能力,但还是不够,所以我想在这里碰碰运气。
我们的平台是 Magento Enterprise 1.9.1.1。
我们使用一种古老的打印解决方案,通过 ODBC 读取订单。因此,我们无法直接从 Magento 的 MySQL 数据库中读取它(由于更改的可能性很高)。我所做的是扩展 Mage_Sales_Model_Order 来拦截 _beforeSave() 函数,并在返回parent::_beforeSave() 之前直接对另一个数据库进行 SQL 查询。可能有更好的方法来做到这一点,但它现在已经完成了,而且功能齐全,而且无论如何这不是我的问题所在。
如果抛出任何 SQL 错误,更新将回滚,并且错误和错误将被删除。订单数据被传递到一个函数,该函数将包含错误信息的电子邮件发送到邮件列表。 /locale/en_US/template/email/ 中的电子邮件模板文件调用 .phtml 文件来处理数据数组,如下所示:
{{block type='core/template' area='frontend' template='/email/errors/order/beforesave.phtml' orderdata=$orderdata errors=$errors}}
这是我从 /locale/en_US/template/email/sales/shipment_new.phtml 借用的功能。这也是我遇到障碍的地方。如果用户处理订单时遇到错误,则电子邮件可以从前端正常触发。如果您从 adminhtml 进行订单更改,则会发送电子邮件,但不会出现上述块。
我尝试过在块调用中使用和不使用area='frontend',并且脚本无论如何都表现出相同的行为。
我认为问题可能出在我的 XML 中,尽管它发现模板本身从管理和前端都很好(并且不需要在我的 XML 中的任何地方定义此块)。我在 Magento 自己的文件或互联网上的任何地方都找不到任何这样的例子。
任何帮助将不胜感激。这让我很头疼!
- 麦克风
I fear I've stumbled into unknown Magento territory. I have exhausted what's left of my Googling abilities and have come up short, so I thought I'd try my luck here.
Our platform is Magento Enterprise 1.9.1.1.
We use an archaic print solution that reads orders via ODBC. As such, we can't have it read from Magento's MySQL database directly (thanks to the high likelihood of change). What I've done is extend Mage_Sales_Model_Order to intercept the _beforeSave() function with direct SQL queries to another database, before returning parent::_beforeSave(). There are likely better ways to have done this, but it's done now, and functional, and regardless it is not where my problem lies.
If any SQL errors are thrown, updates are rolled back and the errors & order data are passed to a function that sends an email to a mailing list with the error information. The email template file in /locale/en_US/template/email/ calls on a .phtml file to process the arrays of data like so:
{{block type='core/template' area='frontend' template='/email/errors/order/beforesave.phtml' orderdata=$orderdata errors=$errors}}
This is functionality I borrowed from /locale/en_US/template/email/sales/shipment_new.phtml. And this is also where I hit my roadblock. The email fires fine from the front end, if errors are encountered when the user is processing an order. If you make order changes from adminhtml, the email is sent, but without the above mentioned block.
I have tried with and without area='frontend' in the block call, and the script exhibits the same behaviour regardless.
I think that the problem may be in my XML, though it finds the template itself just fine from both admin and frontend (and this block is not required to be defined in my XML anywhere). I can also not find any examples of this within Magento's own files, or anywhere on the internet.
Any help would be more than greatly appreciated. This is doing my head in!
- Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否为实际电子邮件模板设置“区域”?例如:
Are you setting the "area" for the actual email template? E.g.:
在前端和后端之间共享模板可能重复( admin 或 adminhtml) 在 magento 中。
并不是要复活一个已经死了的问题;只是把松散的一端绑起来。
@ColinM:我的想法和你的一样,但这对我来说不起作用。也许我不明白setDesignConfig()的目的。不管怎样,上面的链接对我来说非常有效,与原始海报的场景相同。
Possible duplicate of sharing template between frontend and backend (admin or adminhtml) in magento.
Don't mean to revive a dead question; just tying up the loose end.
@ColinM: My thoughts were the same as yours, but that somehow didn't work for me. Maybe I don't understand the purpose of setDesignConfig(). Anyhow, the link above worked perfectly for me, in the same scenario as that of the original poster.