我在网上搜索了几个小时,但解决方案是针对老版本的Magento,我的版本是1.7.0.2。 Magento处理电子邮件的方式发生了变化。以下是我如何做到这一点的步骤,希望对您有所帮助。
1)改变应用程序/代码/核心/法师/核心/型号/电子邮件/模板/ Mailer.php
Part 1, add protected $emailTemplate; to the top of the class:
class Mage_Core_Model_Email_Template_Mailer extends Varien_Object
{
/**
* List of email infos
* @see Mage_Core_Model_Email_Info
*
* @var array
*/
protected $_emailInfos = array();
// Add the following one line
protected $emailTemplate;
第2部分更新的功能的send()
public function send()
{
// the original was $emailTemplate = Mage::getModel('core/email_template');
// Change it to the following four lines:
if ($this->emailTemplate)
$emailTemplate = $this->emailTemplate;
else
$emailTemplate = Mage::getModel('core/email_template');
第3部分添加功能到类的末尾:
public function addAttachment(Zend_Pdf $pdf, $filename){
$file = $pdf->render();
$this->emailTemplate = Mage::getModel('core/email_template');
$attachment = $this->emailTemplate->getMail()->createAttachment($file);
$attachment->type = 'application/pdf';
$attachment->filename = $filename;
}
2)更新应用程序/代码/核心/法师/销售/型号/订单/ Invoice.php
Update sendEmail function
$mailer = Mage::getModel('core/email_template_mailer');
// the next two lines were added
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($this));
$mailer->addAttachment($pdf,'invoice.pdf');
if ($notifyCustomer) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($order-
个原始URL是在这里: http://www.ericpan.com/2013/02/14/add-pdf-attachment-to-invoice-email/#.USPAKR2t2-0
您可以发布您的解决方案? – Guus 2013-02-19 09:59:18
嗨,古斯,最后我没有做到这一点。我转向prestashop,magento对我的目的有点困难。祝你好运! – 2013-02-19 12:51:32