数時間オンラインで検索しましたが、解決策は古いバージョンの Magento 用でした。私のバージョンは 1.7.0.2 です。また、Magento がメールを処理する方法が変更されました。これを行う手順は次のとおりです。お役に立てば幸いです。
1) app/code/core/Mage/Core/Model/Email/Template/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) app/code/core/Mage/Sales/Model/Order/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