1

How can I get the template ID by its template name?

enter image description here

Thanks!

1 Answer 1

4

Use this below code to get your email template ID by code :

protected $emailTemplate;

public function __construct(
    ...
    \Magento\Email\Model\BackendTemplate $emailTemplate
    ...
){
    ...
    $this->emailTemplate = $emailTemplate;
    ...
}

public function yourFunction()
{
    $email_template = $this->emailTemplate->load('New Pickup Order', 'template_code');
    echo $email_template->getId();  
}
3
  • 1
    Thank you Rohan! Nov 7, 2019 at 19:03
  • Happy coding :) happy to help!! Nov 7, 2019 at 19:06
  • Nice solution Rohan, only one comment, ... the last line should be getId() rather than getTemplateId()... Thanks again. Aug 26, 2020 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.