In /app/code/local/Mage/Sales/Model/Order/Shipment.php I added the following lines in sendEmail() funtion:
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($invoice));
$mailer->addAttachment($pdf, 'rechnung.pdf');
The file is correctly attached but the order items and invoice ID are missing.
For a test I added this in /app/code/local/Mage/Sales/Model/Order/Invoice.php :
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array($this));
$mailer->addAttachment($pdf, 'rechnung.pdf');
This works 100% correctly.
Anybody see the problem?
Best Answer
I had the same request asked a while back. I used you question and your findings to solve our problem. I am posting in case someone else is in need of a solution.
I am using magento CE 1.9.1
The leg work:
"You never want to edit the core files always create an overwrite" and if you are really good create modules.
move
"app/code/core/Mage/Core/Model/Email/Template/Mailer.php"
to"app/code/**local**/Mage/Core/Model/Email/Template/Mailer.php"
move
"/app/code/core/Mage/Sales/Model/Order/Shipment.php"
to"/app/code/**local**/Mage/Sales/Model/Order/Shipment.php"
Coding:
Mailer.php
add a protected variable before the first function declaration
protected $emailTemplate;
Modify the Send function
.
.
Shipment.php
$storeId = $order->getStore()->getId();
add:.
$mailer = Mage::getModel('core/email_template_mailer')
; add:.
I found my answer in Add PDF attachment to invoice email