Email templates in Magento 1.9 (Magento Front end developer certification)

Feb 12, 20181315Yaroslav Tobolich
Email templates in Magento 1.9 (Magento Front end developer certification)

Customizing Magento involves many various things, but when it comes to email templates, the area usually gets neglected. That’s why today’s article is about email templates, the ways to create them, use variables and add the images as well as links.

Customization of transactional email templates

Create and assign custom transactional email templates

In order to create an email template, you need to go to the System->Transactional Emails.

transactional-emails

Then you need to add a new template by clicking the ‘Add New Template’ button add-new-template

Fill in the forms (for example, as it is in the contact form).

forms

Assign it in the System/Configuration, and then Sales/Sales Emails as it’s shown in the picture.

sales-emails

Use of template variables available in each email {store, var, …} and how to access properties of variable objects (for example var order.getCustomer.getName)

Actually, there are many variables that can be used in the email templates. The essentials are considered to be var, store, inlinecss, template.

Besides, there’re conditions as in PHP: {if} {/if}

For example, as it’s used in the template (/app/locale/en_US/template/email/password_or_email_changed.html):

Here we also can see how inlinecss is added to the email template:

NOTE: I marked the condition with bold type and showed the way how to add inline style in the email template.

In order to use variables in email templates, you need to use the ‘get’ PHP method:

For example, as it’s used in the template (/app/locale/en_US/template/email/html/footer.html):

Link to custom images from transactional email templates

In order to include a custom image in the email template, you need to put the following tags:

  • When adding an image from template: {{skin url='images/imagename.jpg'}}
    edit-email-template
  • When adding an image from media: {{media url='images/imagename.jpg'}}

Create links to store pages in transactional email templates

In order to create a link to store pages in email templates, you need to use the following construction: {{store url=""}}

For example, like that

email-template-example
or like in the template (app/locale/en_US/template/email/html/header.html):

In case you need to create a link to the category page or other pages, use this construction:



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *