How to Call Helper Function in phtml in Magento 2

Call Helper Function in phtml in Magento 2

Helper classes offer functionalities for many features in Magento 2 stores. With Magento 2, the Helper can be called in controllers, models, views and other helpers. The below code can be used when you want to have helper’s data in .phtml file in Magento 2. Making changes in the default Magento 2 files is not advisable and that’s when the Magento 2 Helper class comes in picture to override the core files. The programmatic method to call helper function in

Continue Reading

How To Enable GZIP Compression for Magento

How To Enable GZIP Compression for Magento

GZIP compression is a standard method to compress files for faster webpage loading. When a visitor visits the site, the server is called to deliver the requested files. If these files are larger in the size, it causes a higher load time. Bigger the file, longer it takes to display the result to the visitor. With GZIP compression, the files are compressed before sending them to the browser, resulting in reducing the load time. According to GTmetrix, GZIP compression reduces

Continue Reading

How to Get the Price Range of Bundle Products in Magento 2

How to Get the Price Range of Bundle Products in Magento 2

Magento 2 Bundled Product is a composite product that has a number of simple or virtual products. The price of bundled products can be either a dynamic or fixed value. For a fixed price for a bundle product, you can enter a base price with applied taxes for it. For the dynamic price, enter the price range from least expensive to the most expensive price. However, when you are selling such bundled products on multiple sales channels such as Facebook where you

Continue Reading

How to Add Attachments with Email in Magento 2.3.x

How to Add Attachments with Email in Magento 2.3.x

The Magento 2.3.x versions use the Zend Framework 2. The implementation of various functionalities is different from the previous versions as it refuses to apply Zend Framework 1 (ZF1). One such function is to send Emails with attachments. With the function createAttachment() in the previous Magento 2 versions, it was easy to add attachments in Emails. However, if you are using the upgraded versions (I’m sure you’re enough concerned with the security and thus using the latest Magento 2.3.2), use

Continue Reading

How to Add Block’s Class Name Dynamically into Layout.xml File in Magento 2

How-to-Add-Block-s-Class-Name-Dynamically-into-Layout_xml-File

Dynamic content is one of the ways to enhance the shopping experience in Magento 2 store. It not only attracts the visitors but boosts the conversion too. For example, you can dynamically display offers based on customer type, location, etc. And one of the ways to do so is the below programmatic method to add block’s class name dynamically into layout.xml file in Magento 2. Method to Add Block’s Class Name Dynamically into Layout.xml File in Magento 2: Create registration.php

Continue Reading

How to Override JS File in Magento 2

How to Override JS File in Magento 2

It is strongly recommended not to change the source code of default Magento components including JS files. However, owing to the business requirements you are bound to go out of the way and override the default function. Here, I have posted the code to override JS file in Magento 2. You may use this code when you want to extend the default JS file to extend a default Magento 2 feature! Method to Override JS File in Magento 2: Create

Continue Reading

List of addAttributeToFilter Conditionals In Magento

List of addAttributeToFilter Conditionals In Magento

Filter collections in Magento or Magento 2 using addAttributeToFilter conditionals. addFieldToFilter is adding WHERE condition in Mysql question to get the collection from the database, allowing to filter the collections like product collection, category collection, and many more by custom conditions. Developing is all about if, when and else most of the time! (Developers, don’t get offended 😄) You may have to use conditions like equal, not equal, like, not like, in, not in, null, not null, greater than, less

Continue Reading

How to Get Parent Product ID in Magento 2

How to Get Parent Product ID in Magento 2

The post shows the programmatic method to get parent product ID in Magento 2. Magento 2 has 3 product types named configurable, bundled and grouped, those have children products. You might be wondering if you can get parent product ID of these 3 product types. You can use the solution if you are selling the store products on 3rd party platforms like Facebook shop and care to enhance the shopping journey. For example, I used the below method for a

Continue Reading

How to Add Custom JS File in Magento 2 Admin Panel

How to Add Custom JS File in Magento 2 Admin Panel

Magento 2 uses the requireJS library, i.e., javascript file loader, to work with JS files. The developers may, however, require to use custom Javascript for additional features not offered by the default Magento 2. For example, a custom module requires functionalities such as to select an image, crop an image, display charts, etc. There are many features that can be implemented using Javascript and improve the Magento 2 admin panel. However, to do so, you need to follow the below steps to

Continue Reading