Skip to content

Instantly share code, notes, and snippets.

@deivisonarthur
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deivisonarthur/9083709 to your computer and use it in GitHub Desktop.
Save deivisonarthur/9083709 to your computer and use it in GitHub Desktop.
Como enviar template customizada pelo magento e como setar variáveis na template. Outra opção é como criar invoice auto e ou apos pagamento no modulo de pagamento enviando email de invoice
<?php
public function sendCustomMail($CustomerName, $email, $increment_id, $template) {
// Load from magento config..
$sender = Array('name' => Mage::getStoreConfig('trans_email/ident_sales/name'), 'email' => Mage::getStoreConfig('trans_email/ident_sales/email') );
$storeId = Mage::app()->getStore()->getId();
$translate = Mage::getSingleton('core/translate');
$datetime = new DateTime();
$dtcancel = $datetime->format('d/m/Y H:i:s');
// Add some custom variables here to pass into the template.
$emailTemplateVariables['CustomerName'] = $CustomerName;
$emailTemplateVariables['increment_id'] = $increment_id;
$emailTemplateVariables['CreatedCancel'] = $dtcancel;
$emailTemplateVariables['store_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
Mage::getModel('core/email_template')
->sendTransactional($template, $sender, $email, $username, $emailTemplateVariables, $storeId);
$translate->setTranslateInline(true);
}
// Dispara email de cancelamento para o cliente - ID da template de cancelamento é 15
$this->sendCustomMail($order->getCustomerName(),$order->getCustomerEmail(),$order->getIncrementId(),"15");
/*
Pode passar objeto dessa forma :O
array(
'rastreamento' => $rastreamento,
'order' => $rastreamento->getOrder()
)
Assim lê na template assim: {{var order.increment_id}} ou {{htmlescape var=$order.getCustomerName()}}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment