Magento 1&2 – Include static block in transactional mail

I actually thought, that I at least for Magento 1 have long written a contribution to it, how to integrate a static block into a transactional email or, more precisely, into an email template, to, for example, terms and conditions, Has cancellation conditions and / or data protection information in one central place and does not have to change in different places in the shop. Not only the ease of work but above all the risk of forgetting a job should not be neglected.

I already had a post on the topic “Static block in CMS / PHTML-Embed page” written, who can also help here, around a block such as. Only having to maintain revocation in one place and CMS page etc.. receive the changes automatically via the block reference.

But now that's the point, the static block directly into the template, e.g.. the order confirmation email, so that the current content of this block is always automatically appended to the mail.

In Magento 1 you just had to insert the following code at the desired location in the mail template:

{{block type="cms/block" block_id="agb"}}

This could either be done individually (in the backend) Insert created templates, which were then used for sending or also directly in the relevant .html file (Template template, which is used by default, if you don't create a special template in the backend) such as. the order_new.html under app / locale / de_DE / template / email / sales.

In Magento 2 goes this -surprise- no longer. Fortunately, however, it is just a slightly changed code, that has to be involved. In the case of our terms and conditions, this is then

{{block class="Magento\\Cms\\Block\\Block" area="frontend" block_id="agb"}}

With this the content of the block “agb” then added to the relevant mail. Here, too, you have the option of either inserting this into the template created in the backend and then assigned via the configuration, or directly into the .html file. However, this is a little more difficult, since the templates can no longer always be found in the same place. In M2, for example, it should. stored in their own template. For example, this COULD be such a path app / design / frontend /[NAME]/[NAME2]/Magento_Sales / email but also a lot more. The other templates can be found e.g.. unter vendor/magento/module-sales/view/frontend/email oder vendor/magento/theme-frontend-luma/Magento_Sales/email

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

Leave a Reply

Your email address will not be published. Required fields are marked *