Magento - Email Template Script

Kevin's picture

One of the most 'curious' tasks in getting a magento eCommerce shop ready to go live is the task of getting all of the email templates altered so that they contain the correct information for your new shop. There's millions of these templates with rather annoying literal strings in 'em like 'Demo Store' etc. For some strange reason the default templates do not pull things like the store name etc. from the (available) backend variables.

We have found that the best way to get these templates changed is not to edit them by hand but to use a script to automatically change the text. We use a shell script based on the one detailed here:

See post #26 from a very kind [url=]charlesrg1[/url]

The strange thing is that it seems that over the course of some minor magento releases some of the text in the default templates changed thus breaking part of this script and others like it, for example 'Magento Demo Store' got changed to 'Demo Store'. I am not going to hazard a guess as to why this text was changed (and hence the scripts broken) instead I will include the script that we used sucessfully with magento version in the hope that it might help someone:

phone="025 46791"
email="[email protected]{{var order.getStoreGroupName()}}"
fops="-type f -exec sed -r -i"
find $tpath/sales $fops 's/alt="Magento"/alt="{{var order.getStoreGroupName()}}"/g' {} \;
find $tpath/sales $fops 's/Magento Demo Store/{{var order.getStoreGroupName()}} /g' {} \;
find $tpath/sales $fops 's/Demo Store/{{var order.getStoreGroupName()}} /g' {} \;
find $tpath/sales $fops "s/mailto:[email protected]/$email/g" {} \;
find $tpath/sales $fops "s/[email protected]/$email/g" {} \;
find $tpath $fops 's/alt="Magento"/alt="{{var}}"/g' {} \;
find $tpath $fops 's/Magento Demo Store/{{var}} /g' {} \;
find $tpath $fops 's/Demo Store/{{var}} /g' {} \;
find $tpath $fops "s/mailto:[email protected]/$email/g" {} \;
find $tpath $fops "s/[email protected]/$email/g" {} \;
find $tpath $fops "s/\(0?800\) ?DEMO-(STORE)|(NUMBER)/$phone/g" {} \;
find $tpath $fops "s/\(555\) 555-0123/$phone/g" {} \;
find $tpath $fops "s/ ?Monday - Friday, 9am - 5pm PST/$office_hours/g" {} \;
find $tpath $fops "s/ ?Monday - Friday, 8am - 5pm PST/$office_hours/g" {} \;
find $tpath $fops 's/logo_email.gif/logo.gif/g' {} \;

There are variables at the top through which you can specify your store's phone number, office hours and target locale. Also, remember to set the store in the Magento Admin as the templates will now use it.

Remember to back up your templates before throwing the script at them and also that your updated templates may be overwritten if you upgrade your magento installation - so keep a backup of your altered email templates and upload them again after an upgrade (if required).

Let us know if it works ok for you or if you find any problems with it, with the feedback I will try to keep the script current & correct.

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c