1

I upgraded our Magento version from 2.3.4 to 2.4.3. After the upgrade the items in the order aren't showing in the email. The email template shows the items using:

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

Per answers in this question I have tried updating the is_legacy column from 0 to 1 in the email_template table. I have also tried the following:

{{layout handle="sales_email_order_items" order=order}}
{{layout handle="sales_email_order_items" order_id=$order_id}}
{{layout handle="sales_email_order_items" order=$order area="frontend"}}
{{layout handle="sales_email_order_items" order_id=$order_id area="frontend"}}

None have worked. Is there something I'm missing?

2 Answers 2

1

Let's try reverting "updating the is_legacy column from 0 to 1 in the email_template table", that means you should update the is_legacy column from 1 to 0 in the email_template table. And use the following code:

{{layout handle="sales_email_order_items" order_id=$order_id area="frontend"}}
0

As of Adobe Commerce and Magento Open Source 2.3.4, custom email templates are only allowed to use scalar values for variable data. Direct calls to methods are no longer allowed.

You will need to modify your templates as per the latest guidelines which is described here.

https://developer.adobe.com/commerce/frontend-core/guide/templates/email-migration/

As a work around you can try the below. (Its not a recommended way but only a temporary fix )

Magento in the earlier version has the below class

\Magento\Framework\Filter\VariableResolver\LegacyResolver

which resolves objects but in the latest version this class is being removed (Security Reason I believe) and we have only the StrictResolver which will not support objects in email templates

\Magento\Framework\Filter\VariableResolver\StrictResolver

The workaround is to copy the content of the LegacyResolver class in to the StrictResolver class (retain the class name).

Note : In case if you are doing this in PROD plz take care of the DI's in __constructor. In Legacy class 2 objects are injected but in Strict only one object in injected.

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.