I want a pdf to be attached with the mail which is sent when I ship my order and tick the option 'Email Copy of shipment'. pdf should contain same content as mail, as only those items list from the order which i had shipped not all items. I know how to attach files with the mail, but what I want to know is how to generate pdf each time and attach with the mail or any other simpler solution.


I have this code that works good app/code/local/Mage/Sales/Model/Order/Shipment.php for sending e-mail to customer with attached invoice when order status changes to "Shipped" :

 `if (strpos($template, 'shipped')){
  $id_factura = $templateVars['{id_order}'];
   $orden = new Order($id_factura);
  $factura['content'] = PDF::invoice($orden, 'S');
   $factura['name'] = $id_factura.'.pdf';
   $factura['mime'] = 'application/pdf';
   $message->attach(new Swift_Message_Attachment($factura['content'], $factura['name'], $factura['mime']));
  • Can you please elaborate how to use the above code, I am new to magento, cant decide where to place the code in Shipment.php
    – Inder
    Jun 30 '15 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.