{"id":2638,"date":"2024-12-31T20:25:46","date_gmt":"2024-12-31T20:25:46","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/solved-undefined-index-directivename-in-simpledirective-php-in-magento-2\/"},"modified":"2025-09-01T10:54:35","modified_gmt":"2025-09-01T05:24:35","slug":"undefined-index-directivename-in-simpledirective-php-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/undefined-index-directivename-in-simpledirective-php-in-magento-2\/","title":{"rendered":"Solved: Undefined Index: DirectiveName in SimpleDirective.php in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Is your Magento 2 store not working properly when an email is supposed to be triggered? Well, this can be because of a custom email template. Follow me till the end of this post to <a href=\"#solution\">find the solution<\/a>.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Magento 2, different email notifications are sent to the customers and admins for various activities. The merchants can <a title=\"Customize Email Templates in Magento 2\" href=\"https:\/\/meetanshi.com\/blog\/customize-email-templates-in-magento-2\/\" target=\"_blank\" rel=\"noopener\">customize the email templates<\/a> according to their needs. Sometimes these custom email templates can create compatibility issues after <a href=\"https:\/\/meetanshi.com\/magento-upgrade-service.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento upgrades<\/a>. Recently, I encountered one such issue in our client&#8217;s Magento store, which was freshly upgraded to <a title=\"Magento 2.3.4\" href=\"https:\/\/meetanshi.com\/blog\/magento-2-3-4-release\/\" target=\"_blank\" rel=\"noopener\">Magento 2.3.4<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento was throwing error 500 when the emails were supposed to be sent through custom templates, i.e. new customer registration, reset customer password, order success, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The error log showed: <em>&#8220;<strong>Undefined Index: DirectiveName in vendormagentoframeworkFilterDirectiveProcessorSimple Directive.php in Magento 2<\/strong>&#8220;<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is because of the <a title=\"Email templates Guide\" href=\"https:\/\/developer.adobe.com\/commerce\/frontend-core\/guide\/templates\/email\/\" target=\"_blank\" rel=\"noopener\">restrictions on the usage of custom variables in Magento 2.3.4 (Adobe Commerce)<\/a>. It can be easily solved by following the <a href=\"https:\/\/developer.adobe.com\/commerce\/docs\/\" target=\"_blank\" rel=\"noreferrer noopener\">custom email template migration guide<\/a> released by Magento.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s see how to fix <strong><em>Undefined Index: DirectiveName in SimpleDirective.php in Magento 2<\/em><\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Solve Undefined Index: DirectiveName in SimpleDirective.php in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In Magento 2.3.4, there have been changes in the custom email template workflow. All the email templates have been converted to &#8216;strict mode&#8217; as referred to by the Magento custom email template migration guide.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Referring to the same guide, I came to know that the issue was caused by the space in the custom directive code. According to the official resource, <strong>spaces should not be used next to the braces:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Correct:<\/strong> <code>{{var subscriber_data.confirmation_link}}<\/code><br><strong>Incorrect:<\/strong> <code>{{ var subscriber_data.confirmation_link }}<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span id=\"solution\">In order to solve the issue:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Step 1: <\/strong>Log into your Magento admin and go to <strong>Marketing &gt; Communications &gt; Email Templates<\/strong>.<\/li>\n\n\n\n<li><strong>Step 2:<\/strong> Select the custom email template and search for <code>{{ <\/code>in the template content to find the directive code with space next to braces.<\/li>\n\n\n\n<li><strong>Step 3:<\/strong> Remove the spaces after <code>{{<\/code> and before <code>}}<\/code>.<\/li>\n\n\n\n<li><strong>Step 4:<\/strong> Save the template.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">&amp; you&#8217;re done!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 custom email templates will start working again..!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Related Solution: <a title=\"Call to Undefined Function bccomp in Magento 2\" href=\"https:\/\/meetanshi.com\/blog\/call-to-undefined-function-bccomp-in-magento-2\/\" target=\"_blank\" rel=\"noopener\">Call to Undefined Function bccomp() in Magento 2<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The custom email template incompatibility in Magento 2.3.4 is a crucial issue. It should be addressed earnestly not to put your store&#8217;s customer experience at stake. It can be easily solved by following Magento&#8217;s custom email template migration guide.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I hope the solution provided here will help you solve the issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Still need any help? Comment down your queries; I&#8217;d be happy to help you.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to share this Magento solution with your friends via social media.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is your Magento 2 store not working properly when an email is supposed to be triggered? Well, this can be because of a custom email&#8230;<\/p>\n","protected":false},"author":13,"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-2638","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2638","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2638"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions"}],"predecessor-version":[{"id":21271,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions\/21271"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}