13

I'm setting up a website running on Magento 2.3.4

I've run into an issue with sending emails to buyers. The email template I created through the admin interface is supposed to show the items bought. However it isn't rendering the section with the layout directive.

This is the line I'm talking about:

{{layout handle="sales_email_order_items" order=$order}}

If i send an email using the default template meant for a new order, then the email contains the itemized list

I'm not quite sure why, but the new strict mode introduced in 2.3.4 seems to have broken how the layout directive works.

Does anyone know how to render the itemized list from the order in the email?

4 Answers 4

29

Temp solution is:

set in db table: email_template column is_legacy = 1 for this new order email template.

3
  • This is not working in magento 2.4.1 enterprise edition
    – devhs
    Commented Mar 2, 2021 at 10:59
  • working fine, thank you! Commented Dec 29, 2021 at 10:29
  • what means legacy template
    – Ramesh KR
    Commented May 16, 2022 at 14:17
6

put this line instead of the one you have: {{layout handle="sales_email_order_items" order_id=$order_id area="frontend"}}

4

I had the same problem.

the solution of Domagoj Potkoč is ok but temp.

This module fix the bug - it will automated previous solution: FixAdminEmailTemplate

0

create plugin to resolve this

di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Email\Model\Template">
        <plugin disabled="false" name="FixAdminEmailTemplate_Plugin_Magento_Email_Model_Template" sortOrder="10" type="Test\Module\Plugin\EmailTemplate"/>
    </type>
</config>

EmailTemplate.php

<?php
declare(strict_types=1);

namespace Test\Module\Plugin;

class EmailTemplate 
{
    public function beforeBeforeSave(\Magento\Email\Model\Template $subject)
    {
        $subject->setData('is_legacy', 1);
        return [];
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.