按姓名获取跨国电子邮件id


Get transcational email id by name

有人知道我如何通过在后端设置的名称获取电子邮件的id吗?我在事务电子邮件的后端创建了一封电子邮件,我想用程序发送它,但它的id可能会因我所在的实例(本地、现场、舞台)而异,我只能为它提供相同的名称。我有这个:

Mage::getModel('core/email_template')->sendTransactional(
$templateId, 
$sender, 
$recepientEmail, 
$recepientName, 
$vars, 
$store);

我需要找到$templateId,我只知道我保存了名为"Tests"的邮件。

您可以获得电子邮件模板:

$templateName = “Test”;
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateName);

获取id:

$templateId = $emailTemplate->getId();

然后在路上发送电子邮件:

Mage::getModel('core/email_template')->sendTransactional(
    $templateId, 
    $sender, 
    $recepientEmail, 
    $recepientName, 
    $vars, 
    $store
);

或者使用"我的"方法:

$vars = array('key' => 'value');
$storeId = Mage::app()->getStore()->getStoreId();
$recipientEmail = 'some@email.com';
$recipientName = 'Some Name';
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', $storeId)); 
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', $storeId));    
$emailTemplate->send($recipientEmail, $recipientName, $vars);
请检查下面的代码。不管怎样,这是我对stackoverflow的第一个回答。
$templateName = "Tests";
$templateID = Mage::getModel('core/email_template')->loadByCode($templateName)->getId();