Pass Order Data from Admin Email Template to Block?

by MagentoAaron   Last Updated August 01, 2020 13:09 PM

Is it possible to pass $order details to custom block from an email template override in the Magento Admin?

I created an override template of the RMA Status notification email in the admin at Marketing > Communications > Email Templates.

I tried using the following to send $order but it's NULL:

{{block class="Vendor\Module\Block\Rma\Rmastatus" order=$order template="Vendor_Module::rma/rmainstructions.phtml"}}

I have a module with a frontend template and a block class: Vendeor/Module/view/frontend/templates/rma/rmainstructions.phtml

<?php

use Vendor\Module\Block\Rma\Rmastatus;

/** @var $block Rmastatus */
?>
<?php
$order = $this->getData('order');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$logger = $objectManager->get("Psr\Log\LoggerInterface");
$logger->debug($order); // Logs as report.DEBUG: NULL [] []
$logger->debug(var_export($order->getID(), true)); // Logs as report.DEBUG: NULL [] []
?>
<span class="return-status">RMA Status: <?= $block->getRmaStatus($order); ?></span>

If this is not possible, can you suggest another approach?


Related Questions


Email Order Items Template Adjustment - Magento 2

Updated March 06, 2019 06:09 AM

Show order variables programmatically in html template

Updated October 13, 2017 10:09 AM