Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Transactional email template. How do I replace emails in templates in on time
 
m00v
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2008-07-31
 

Hi, I didn’t know where to post it but i guess some people will be interested.

Magento Team provides templates for the transactional emails in English. They are accessible through admin -> system -> transactional email.
Well, of course you can create every template one by one then look for the emails addresses and “Magento” are replace it.

But you can also easily open a shell, go to ROOTPATH/magento/magento/app/locale/en_US/template/email/sales/ and type :

awk '{gsub("magento@varien.com", "yournewmail@yourdomain.com", $0); print > FILENAME}' *.html
awk 
'{gsub("dummyemail@magentocommerce.com", "yournewmail@yourdomain.com", $0); print > FILENAME}' *.html
awk 
'{gsub("Magento", "Yourstorename", $0); print > FILENAME}' *.html

This applies also in ROOTPATH/magento/magento/app/locale/en_US/template/email/
But there, it will be better to start by replacing first “Magento Demo Store” and then “Magento”.

Then every time you create a template, the emails should be properly set as well as the alternative text for the logo_email and your shop name.
It will avoid you to create every template at least once, meaningless there are 33 of them...* 3 fields + the potential mistakes you can do in the tiny 270px wide text-area.

If you have a multiple language store you’ll see the interest quickly wink

NB : Awk is useful when you are working on a linux/unix, otherwise the “Replace in Files” function of your favorite editor does the job.

Best regards.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hulaqueen
Jr. Member
 
Total Posts:  19
Joined:  2008-09-20
 

I’ve raised a bug tracker report suggesting the templates be changed to dynamically use store information.... please comment if you wish at:
http://www.magentocommerce.com/bug-tracking/issue?issue=3854

It would be great to get this included with the next release.

Thanks,
Sheryl

 
Magento Community Magento Community
Magento Community
Magento Community
 
GelbachDesigns
Jr. Member
 
Total Posts:  8
Joined:  2009-02-13
 

m00v, you are awesome.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

good one m00v.

Anyone else doing this before they make the information dynamic (fingers crossed)

You will also want to change:-

“(555) 555-0123” to your phone number
“Monday - Friday, 8am - 5pm PST” to your opening times and timezone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
AITOC
Guru
 
Avatar
Total Posts:  618
Joined:  2009-02-19
US
 

Hi, now you can replace dummy data or any custom string from admin interface. For more details see E-mail Templates Manager extension page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
freshshop
Sr. Member
 
Avatar
Total Posts:  88
Joined:  2009-03-07
 

Hi,

I’ve been searching for hours and cannot make this to work: How can I edit the customer name at the email templates so it only shows the First Name and not the complete name: Hello James Smith sounds too serious for me. I would prefer it to say Hello James, ...

I have tried putting the variable {{var getCustomer.firstname}} but it does not work.

Any ideas?

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gregersen
Member
 
Total Posts:  57
Joined:  2008-06-15
 
jungleshop - 09 January 2010 03:54 PM

Hi,

I’ve been searching for hours and cannot make this to work: How can I edit the customer name at the email templates so it only shows the First Name and not the complete name: Hello James Smith sounds too serious for me. I would prefer it to say Hello James, ...

I have tried putting the variable {{var getCustomer.firstname}} but it does not work.

Any ideas?

thanks

Did you find a solutions to this?

Or does anyone else have a good idea to only show the customers firstname in emails?

 
Magento Community Magento Community
Magento Community
Magento Community
 
SetuBridgeDev
Member
 
Avatar
Total Posts:  50
Joined:  2009-01-03
 

Hi Every one ,

i am also interested in creating dynamic email template. I have multiple website and want to have different email template for all of them.
I dont like to insert 20- 25 email template from admin , it will take too much time . Is there any solution that i can have the theme based email folder so i can use multiple theme and multiple email template for all the website.

Please help me out from this .

Thanks .

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hacktor
Jr. Member
 
Total Posts:  4
Joined:  2009-07-02
 

I have a multi store Magento 1.3.3 implementation and ran into this topic as I was about to duplicate all mail templates just to get the different store email addresses and store names in all templates and couldn\’t find the store/sender email address in the collection of available variables - as listed in the wiki article: http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/system_email_template/index

I found a work around that is hopefully of use to some of you.

All I needed was a variable in the mail template for the shop (=sender) email address and the sender name.

What I did was sub class Mage_Core_Model_Email_Template
The original class is defined in app\\code\\core\\Mage\\Core\\Model\\Email\\Template.php

I created a Template.php file in the directory
app\\code\\local\\MyCompany\\Core\\Model\\Email

Contents of this file:

class MyCompany_Core_Model_Email_Template extends Mage_Core_Model_Email_Template
{

    
/**
     * Send transactional email to recipient with extra variables: mail sender and sender name.
     *
     * @param   int $templateId
     * @param   string|array $sender sneder informatio, can be declared as part of config path
     * @param   string $email recipient email
     * @param   string $name recipient name
     * @param   array $vars varianles which can be used in template
     * @param   int|null $storeId
     * @return  Mage_Core_Model_Email_Template
     */
    
public function sendTransactional($templateId$sender$email$name$vars=array(), $storeId=null)
    
{
        $vars[\
'sender\']=$this;
        return 
parent::sendTransactional($templateId$sender$email$name$vars$storeId);
    
}
}

so it just adds the sender info to the list of variables you can use in the mail template

Next you have to create a config.xml file to define the subclass. That is file config.xml in directory
app\\code\\local\\MyCompany\\Core\\etc

<config>    
    <
modules>
       <
MyCompany_Core>
            <
version>0.1.0</version>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyCompany_Core>
    </
modules>
    <global>
        <
models>
            <
core>
                <
rewrite>
                  <
email_template>MyCompany_Core_Model_Email_Template</email_template>
                </
rewrite>
            </
core>
        </
models>
    </global>
</
config>

and you should create a MyCompany_Core.xml file in directory
app\\etc\\modules

<?xml version=\"1.0\"?>
<config>
    <
modules>
        <
MyCompany_Core>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyCompany_Core>
    </
modules>
</
config>

This gives you a variable sender in your mail template and allows for template content like:

<p>For questions please contact us: <a style=\"color: rgb(30, 126, 200);\" href=\"mailto:{{var sender.getSenderEmail()}}\">{{var sender.getSenderEmail()}}</a> </p>
                            <
p>Kind regards,</p>
    <
p><strong>{{var sender.getSenderName()}}</strong></p

It will insert the sender mail and name you have defined in the email addresses of the shop that can be configured per site, store and view.

Note that in a similar way you can add additional variables to the vars array.
Cheers.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top