I want to send custom email.In that i have to display multiple customers and customers cart items.For that I have created a custom module.In that I have written model to get all the needed data.How can I display the multiple items and multiple customers information in the email template.Thanks in advance.
1 Answer
To use loop in email templates you need to use a default Magento block.
{{block
class='Magento\\Framework\\View\\Element\\Template'
template='VendorName_ModuleName::email/some-template.phtml'
area='frontend'
customers=$customers
}}
In the created template file you may use the php foreach.
<?php foreach ($block->getData('customers') as $customer): ?>
<?= $block->escapeHtml($customer->getFirstname()) ?>
<?php endforeach; ?>