0

I need to add a custom variable with my module in Mage_Core_Email_Template_Filter for to use in transactional email. I have tried: config.xml

    <core> 
        <rewrite>
            <email_template_fitler>Mage_Core_Email_Template_Filter</email_template_fitler>
        </rewrite>
        </core>

Filter.php

<?php
class ITEP_Incomm_Model_Template_Filter extends Mage_Core_Email_Template_Filter
{
    //variavel para obter código de validação
    public function codeValidationDirective($construction) {
        $params = $this->_getIncludeParameters($construction[2]); 
        return print_r('1142111e2e1we321123211');
        } 
}

and using with {{codeValidation}}, {{customVar code=codeValidation}} but in preview of template the result is the text {{codeValidation}} and not the real value. Why i need to modify? thanks in advance. My cache is off, and clear.

1
  • I think you are working at the wrong place. You don't need to create a Directive for that matter. In which transactional e-mails do you need to include that variable (customer registration, order,...)? You might be interested in this answer: stackoverflow.com/a/11397373 Commented Jun 15, 2015 at 11:05

1 Answer 1

0

i solved settting the variables in file email.php where is send and catch and shows in real email sended, like this: USE in template mail: {{var NAMEVAR}}, and the email.php:

<?php

// How to send.
if (!isset($_GET['email'])) {
    echo 'usage: [email protected]';
    die;
}

// Send mail, the Magento way:
require_once('app/Mage.php');
Mage::app();

$template_id = 'Name_Template';
$SomeVar1 = "ABC";
$Customvar2= "Skype";

// Loads the template exception
$emailTemplate = Mage::getModel('core/email_template')->loadDefault($template_id);

$vars = array("some var" => $SomeVar1 , "custom var is" => $Customvar2);
$emailTemplate->getProcessedTemplate($vars);
echo Mage::getStoreConfig('trans_email/ident_general/name', $storeId);

// Set sender information:
$storeId = Mage::app()->getStore()->getId();
$emailTemplate->setSenderEmail(
        Mage::getStoreConfig('trans_email/ident_general/email', $storeId));
$emailTemplate->setSenderName(
        Mage::getStoreConfig('trans_email/ident_general/name', $storeId));
$emailTemplate->setTemplateSubject('template customized email'); //subject for email
// Send the mail:
$output = $emailTemplate->send($_GET['email'], null, $vars);
var_dump($output);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.