Skip to content

Instantly share code, notes, and snippets.

@mhhansen
Last active August 29, 2015 14:02
Show Gist options
  • Save mhhansen/22a16b7c333d775fb486 to your computer and use it in GitHub Desktop.
Save mhhansen/22a16b7c333d775fb486 to your computer and use it in GitHub Desktop.
MageMonkey Mandrill + WebShopApps PDF Invoicing : Attachments
/**
* Webshopapps_Invoicing
* File: app/code/community/Webshopapps/Invoicing/Sales/Model/Order/Invoice.php
*
* Change addAttachment() function at the end of the file, to use this content
*/
public function addAttachment($mailTemplate,$pdf, $filename) {
$file=$pdf->render();
$mailTemplate->getMail()->createAttachment(
$file,
'application/pdf',
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
$filename
);
}
/**
* Webshopapps_Invoicing
* File: app/code/community/Webshopapps/Invoicing/Sales/Model/Order.php
*
* Change addAttachment() function at the end of the file, to use this content
*/
public function addAttachment($mailTemplate,$pdf, $filename) {
$file=$pdf->render();
$mailTemplate->getMail()->createAttachment(
$file,
'application/pdf',
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
$filename
);
}
/**
* MageMonkey_Mandrill
* File: app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php
*
* Fillout this two functions:
* https://github.com/ebizmarts/magemonkey/blob/master/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php#L157
* https://github.com/ebizmarts/magemonkey/blob/master/app/code/community/Ebizmarts/Mandrill/Model/Email/Template.php#L165
*/
public function createAttachment($body,
$mimeType = Zend_Mime::TYPE_OCTETSTREAM,
$disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
$encoding = Zend_Mime::ENCODING_BASE64,
$filename = null)
{
$mp = new Zend_Mime_Part($body);
$mp->encoding = $encoding;
$mp->type = $mimeType;
$mp->disposition = $disposition;
$mp->filename = $filename;
$this->addAttachment($mp);
return $mp;
}
public function addAttachment(Zend_Mime_Part $att)
{
$this->getMail()->addPart($att);
$this->getMail()->hasAttachments = true;
return $this->getMail();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment