{"id":12731,"date":"2014-07-17T06:55:30","date_gmt":"2014-07-17T06:55:30","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=12731"},"modified":"2015-03-26T10:40:53","modified_gmt":"2015-03-26T10:40:53","slug":"magento-iteration-email-template","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/","title":{"rendered":"Magento Collection Iteration in Email Template"},"content":{"rendered":"<p>In this blog i&#8217;ll discuss about how to iterate(using foreach loop) the Collection in your custom email templates.<\/p>\n<p>Let&#8217;s think situations like when you have to send an email which contains multiple customer addresses or product items, then you must need to iteration the collections in your custom email template.<\/p>\n<p>Magento provide very simple architecture to implement this feature in your project:<\/p>\n<p><strong>Step 1:<\/strong> Add Below line in your email template<\/p>\n<pre class=\"brush:php\">{{block type='core\/template' area='frontend' template='yourmodule\/email_template.phtml' addresses=$addresses}}<\/pre>\n<p><strong>template:-<\/strong> here you have to specify your custom phtml file path which should be kept inside magento frontend part.<\/p>\n<p><strong>addresses:-<\/strong> it&#8217;s your Address collection which you want to iterate(using foreach loop) in your phtml file.<\/p>\n<p><strong>PHTML Path:-<\/strong>\u00a0app\/design\/frontend\/default\/default\/template\/yourmodule<\/p>\n<p>Now you can easily fetch your $addresses inside your phtml file like below:<\/p>\n<pre class=\"brush:php\">&lt;?php \r\nforeach ($this-&gt;getAddresses(); as $address): ?&gt;\r\n    &lt;p&gt;&lt;?php echo $address['name'] ?&gt;&lt;\/p&gt;\r\n&lt;?php endforeach; ?&gt;<\/pre>\n<p>Now It&#8217;s done you&#8217;re ready to send the email with multiple addresses.<\/p>\n<p>I Hope this blog will help someone who needs above feature.<\/p>\n<p>Thanks<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog i&#8217;ll discuss about how to iterate(using foreach loop) the Collection in your custom email templates. Let&#8217;s think situations like when you have to send an email which contains multiple customer addresses or product items, then you must need to iteration the collections in your custom email template. Magento provide very simple architecture <a href=\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":9,"featured_media":22126,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,599,1149],"tags":[1347,2056,775],"class_list":["post-12731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-magento-1-8","category-magento1-9","tag-email","tag-magento","tag-template"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento Collection Iteration in Email Template<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento Collection Iteration in Email Template\" \/>\n<meta property=\"og:description\" content=\"In this blog i&#8217;ll discuss about how to iterate(using foreach loop) the Collection in your custom email templates. Let&#8217;s think situations like when you have to send an email which contains multiple customer addresses or product items, then you must need to iteration the collections in your custom email template. Magento provide very simple architecture [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-17T06:55:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-03-26T10:40:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ravi Raushan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ravi Raushan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\"},\"author\":{\"name\":\"Ravi Raushan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/6230878ae40777e82fbc6eaab40da1a4\"},\"headline\":\"Magento Collection Iteration in Email Template\",\"datePublished\":\"2014-07-17T06:55:30+00:00\",\"dateModified\":\"2015-03-26T10:40:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\"},\"wordCount\":163,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png\",\"keywords\":[\"Email\",\"magento\",\"template\"],\"articleSection\":[\"magento\",\"Magento 1.8\",\"magento1.9\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\",\"name\":\"Magento Collection Iteration in Email Template\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png\",\"datePublished\":\"2014-07-17T06:55:30+00:00\",\"dateModified\":\"2015-03-26T10:40:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento Collection Iteration in Email Template\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/6230878ae40777e82fbc6eaab40da1a4\",\"name\":\"Ravi Raushan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2fc5efdddd710431b898d28d68ac8174ce99bd0448f7edb6e6cae425fffeb374?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2fc5efdddd710431b898d28d68ac8174ce99bd0448f7edb6e6cae425fffeb374?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ravi Raushan\"},\"description\":\"Odoo developer with expertise in Python, JavaScript, and headless development services. He crafts innovative, high-performance solutions that push the boundaries of technology, leveraging his proficiency to build flexible, scalable applications and drive digital transformation.\",\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/ravi-raushan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento Collection Iteration in Email Template","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/","og_locale":"en_US","og_type":"article","og_title":"Magento Collection Iteration in Email Template","og_description":"In this blog i&#8217;ll discuss about how to iterate(using foreach loop) the Collection in your custom email templates. Let&#8217;s think situations like when you have to send an email which contains multiple customer addresses or product items, then you must need to iteration the collections in your custom email template. Magento provide very simple architecture [...]","og_url":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2014-07-17T06:55:30+00:00","article_modified_time":"2015-03-26T10:40:53+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png","type":"image\/png"}],"author":"Ravi Raushan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ravi Raushan","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/"},"author":{"name":"Ravi Raushan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/6230878ae40777e82fbc6eaab40da1a4"},"headline":"Magento Collection Iteration in Email Template","datePublished":"2014-07-17T06:55:30+00:00","dateModified":"2015-03-26T10:40:53+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/"},"wordCount":163,"commentCount":1,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png","keywords":["Email","magento","template"],"articleSection":["magento","Magento 1.8","magento1.9"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/","url":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/","name":"Magento Collection Iteration in Email Template","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png","datePublished":"2014-07-17T06:55:30+00:00","dateModified":"2015-03-26T10:40:53+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-iteration-email-template\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2013\/06\/All-Blogs-Blog-Post-Banner3.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-iteration-email-template\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento Collection Iteration in Email Template"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/6230878ae40777e82fbc6eaab40da1a4","name":"Ravi Raushan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2fc5efdddd710431b898d28d68ac8174ce99bd0448f7edb6e6cae425fffeb374?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2fc5efdddd710431b898d28d68ac8174ce99bd0448f7edb6e6cae425fffeb374?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ravi Raushan"},"description":"Odoo developer with expertise in Python, JavaScript, and headless development services. He crafts innovative, high-performance solutions that push the boundaries of technology, leveraging his proficiency to build flexible, scalable applications and drive digital transformation.","sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/ravi-raushan\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/12731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=12731"}],"version-history":[{"count":11,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/12731\/revisions"}],"predecessor-version":[{"id":21706,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/12731\/revisions\/21706"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/22126"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=12731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=12731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=12731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}