Magento 1.9 – Layout XML for Email Templates

ce-1.9.0.1email-templateslayout

If I create a email template in System > Transactions Email what xml layout is used?

What is the block type here?

Best Answer

This questions is actually a bit too broad but I'd like to give some insights on that:

When you create a transaction e-mail template via the adminhtml section, the content of the corresponding mail template from app/locale/[language_country]/template/email/[filename].html is copied to the database.

As an example for the "New account" e-mail, the declaration can be found in app/code/core/Mage/Customer/etc/config.xml:

<template>
            <email>
                <customer_create_account_email_template translate="label" module="customer">
                    <label>New account</label>
                    <file>account_new.html</file>
                    <type>html</type>
                </customer_create_account_email_template>
                ...
            </email>
</template>

If the e-mail is being sent, the HTML-template is parsed and the variable and block directives ({{store url=""}}, {{layout handle="sales_email_order_items" order=$order}} from the order_new.html template,...) are then replaced by their corresponding blocks defined in the XML-files.

<sales_email_order_items> can be found in app/design/frontend/base/default/layout/sales.xml where also the block type (<block type="sales/order_email_items" ...> in this case) is defined.

The mail classes of Magento responsible for e-mail sending are Mage_Core_Model_Email_Templateand Mage_Core_Model_Email_Template_Filter.