{"id":898,"date":"2020-03-23T14:41:36","date_gmt":"2020-03-23T14:41:36","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/03\/23\/get-list-of-email-templates-programmatically-in-magento-2\/"},"modified":"2025-05-22T14:41:22","modified_gmt":"2025-05-22T09:11:22","slug":"get-list-of-email-templates-programmatically-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-list-of-email-templates-programmatically-in-magento-2\/","title":{"rendered":"How To Get A List of Email Templates Programmatically In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Recently, during a custom extension development, there was a requirement to send customers\u2019 an Email regarding the price. And, for this, I had to load all the default Magento Email templates.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot-at-March-20th-2020-11.53.58-am.png\" alt=\"Email template list in Magento 2\" class=\"wp-image-8203\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">I used the below code to&nbsp;<em><strong>get a list of Email templates programmatically in Magento 2<\/strong><\/em>&nbsp;and you can use it too, whenever you want to send an Email from the Magento 2 store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select the desired Email template from the list and hence the right Email will be sent accordingly to the customers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to get a list of Email templates programmatically in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<em><strong>app\/code\/Vendor\/Extension\/Helper\/Data.php<\/strong><\/em>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Vendor\\Extension\\Helper;\n\nuse Magento\\Framework\\App\\Helper\\AbstractHelper;\nuse Magento\\Framework\\App\\Helper\\Context;\nuse Magento\\Email\\Model\\Template\\Config;\n\nclass Data extends AbstractHelper\n{\n    private $emailTemplateConfig;\n\n    public function __construct(Context $context, Config $emailTemplateConfig)\n    {\n        $this->emailTemplateConfig = $emailTemplateConfig;\n        parent::__construct($context);\n    }\n\n    public function getEmailTemplateOptionArray()\n    {\n        return $this->emailTemplateConfig->getAvailableTemplates();\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the solution to fellow developers via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, during a custom extension development, there was a requirement to send customers\u2019 an Email regarding the price. And, for this, I had to load&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-898","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=898"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/898\/revisions"}],"predecessor-version":[{"id":15014,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/898\/revisions\/15014"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}