I'm trying to add a phtml block to the sales email using the admin area to edit the template. In Magento 1.x this worked fine, however I'm not sure how to do this the same way in Magento 2.3x?
I've added {{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='Vendor_Module::email/ordertrustpilot_afs.phtml'}}
to the template, however I get an error in the log for main.CRITICAL: Invalid template file: 'Vendor_Module::email/ordertrustpilot_afs.phtml' in module: '' block's name: 'magento\framework\view\element\template_0' [] []
Where should I place the phtml file in Magento 2.3x for this to work as intended?
Many thanks
EDIT:
Following Amitkumar's advice I can now output using phtml, however I now need to see why the code in the phtml does not work. I'm using the same code as I did in Magento 1.x which is now obviously wrong.
echo "START";
works at the beginning of the phtml and shows in the email content, however the rest of the code doesn't seem to execute or produce an output or an error.
The code used is below and should output various order details needed to send to Trust Pilot to automate product reviews:
<?php echo "START"; ?>
<?php $finalorderid = $this->getIncrementId() ?>
<?php $_order = $this->getOrder(); ?>
<?php if (!empty($_order)): ?>
<?php $orderId = $_order->getIncrementId(); ?>
<?php $orderRecipientName = $_order->getCustomerName(); ?>
<?php $orderRecipientEmail = $_order->getCustomerEmail(); ?>
<?php $productsData = ""; ?>
<?php $i=0; foreach ($_order->getAllItems() as $_ship): ?>
<?php $_item = Mage::getModel('catalog/product')->load($_ship->getProductId()); ?>
<?php $productsData .= ($i == 0) ? "{" : ",{" ?>
<?php $productsData .= '"productUrl": "'.Mage::getBaseUrl().$_item->getData('url_key').'.html",'; ?>
<?php $productsData .= '"imageUrl": "'.$_item->getImageUrl().'",'; ?>
<?php $productsData .= '"name": "'.$_item->getName().'",'; ?>
<?php $productsData .= '"sku": "'.$_item->getSku().'",'; ?>
<?php $productsData .= '}'; $i++;?> <?php endforeach; ?>
<?php echo '<script type="application/json+trustpilot">{'; ?>
<?php echo '"templateId": "599c4755e05df80becabb8ae",'; ?>
<?php echo '"locale": "en-GB",'; ?>
<?php echo '"recipientEmail": "'.$orderRecipientEmail.'",'; ?>
<?php echo '"recipientName": "'.$orderRecipientName.'",'; ?>
<?php echo '"referenceId": "'.$orderId.'"'; ?>
<?php if (!empty($productsData)): ?>
<?php echo ', "products": ['; ?>
<?php echo $productsData; ?>
<?php echo ']'; ?>
<?php endif; ?>
<?php echo '}'; ?>
<?php echo '</script>'; ?>
<?php endif; ?>