Last active
October 25, 2018 12:51
-
-
Save Maksold/6139664 to your computer and use it in GitHub Desktop.
#magento - Create Transactional Email in #migration script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var $installer Scandi_Migrations_Model_Resource_Setup */ | |
$installer = $this; | |
$installer->startSetup(); | |
$templates = array( | |
array( | |
"name" => "New Invoice", | |
"code" => "sales_email_invoice_template", | |
"config" => "sales_email/invoice/template", | |
), | |
array( | |
"name" => "New Invoice for Guest", | |
"code" => "sales_email_invoice_guest_template", | |
"config" => "sales_email/invoice/guest_template", | |
), | |
array( | |
"name" => "New Order", | |
"code" => "sales_email_order_template", | |
"config" => "sales_email/order/template", | |
), | |
array( | |
"name" => "New Order for Guest", | |
"code" => "sales_email_order_guest_template", | |
"config" => "sales_email/order/guest_template", | |
) | |
); | |
foreach ($templates as $template) { | |
// Load email template from file | |
$fileTemplate = Mage::getModel('core/email_template')->loadDefault($template["code"]); | |
// Create email template | |
$templateDb = Mage::getModel('core/email_template') | |
->setTemplateCode($template["name"]) | |
->setTemplateSubject($fileTemplate->getTemplateSubject()) | |
->setTemplateText($fileTemplate->getTemplateText()) | |
->setTemplateStyles($fileTemplate->getTemplateStyles()) | |
->setModifiedAt(Mage::getSingleton('core/date')->gmtDate()) | |
->setOrigTemplateCode($template["code"]) | |
->setOrigTemplateVariables($fileTemplate->getOrigTemplateVariables()) | |
->setTemplateType(Mage_Core_Model_Email_Template::TYPE_HTML) | |
->save(); | |
// Set this template in config | |
$installer->setConfigData($template["config"], $templateDb->getId()); | |
} | |
$this->endSetup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment