Skip to main content

Posts

Showing posts from June, 2020

Custom email templates in Magento2

Custom email templates in Magento2 In this blog, we’ll discuss how we can create custom email templates and insert variables in email templates of magento2.  Declare email template  Create email_templates.xml inside Vendor/Module/etc/ folder.  <? xml version = "1.0" encoding = "UTF-8" ?> < config xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"        xsi:noNamespaceSchemaLocation = "../../../Magento/Email/etc/email_templates.xsd" >    < template id = "custom_module_email_template" label = "custom_module_email_template" file = "custom_email.html" type = "html" module = "Blog_Management" area = "frontend" /> </ config > Here,  Id is a unique identifier for email templates which we’ll use while declaring which email template we want to use while sending email.  label is a displayed name of an email template.  file is a html file in which is used

Creating a view using ViewModels in Magento2

Creating a view using ViewModels in Magento2 ViewModels are created in order to improve the concept of using Blocks in Magento2. In this tutorial, we are going to discuss how we can use ViewModels in Magento2.  Versions in which we can use ViewModels We can use ViewModels in Magento 2.2 and greater versions , XSI object to declare ViewModels in xml file is not available in Magento 2.0 and 2.1.  Why use ViewModels instead of Blocks  The concept of ViewModels is introduced to get rid of complex block classes and create separate classes that are easy to maintain. Here we are saying complex block classes because whenever we create a block class it extends \Magento\Framework\View\Element\Template class but if a block class is doing some major functionality we have to use some other dependencies too and we can add those dependencies by overriding the PHP constructor and add your dependencies into it. And whenever we override the constructor we have to pass parent dependencies into the par