15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
To load the Email template by template Id paste the following code.
<?php
namespace VendorName\ModuleName\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Email\Model\Template as coreTemplate;
class Data extends AbstractHelper
{
protected $template;
public function __construct(
Context $context,
coreTemplate $template
)
{
$this->template = $template;
parent::__construct($context);
}
public function templateText($templateId)
{
if (is_numeric($templateId)) {
$this->template->load($templateId);
} else {
$this->template->setForcedArea($templateId);
$this->template->loadDefault($templateId);
}
// another method
if (is_numeric($templateId)){
$template = $this->template->load($templateId, 'template_id');
}else {
$template = $this->template->load($templateId, 'template_code');
}
$templateText = $this->template->getTemplateText();
return $templateText;
}
}