Magento 2 – How to Query Data into Email Template

email-templatesmagento2

Assume that I have customer_code in the sales_order_detail table. and I have created a view that store this column with increment_id.

How can I query that column into an email template by using increment_id?

I have called "var order.increment_id |raw":"Order Id" into template. but I don't know how to query the data in the template file.

Best Answer

Have you tried this https://magento.stackexchange.com/a/161053/77554

This might be needed to override the Magento/Sales/Model/Order.php

Please try your luck and let me know

Happy coding