Magento 2 clear – flush cache programmatically

Published on

Magento 2 clear – flush cache programmatically. In this post, let’s find out how to clear/flush cache programmatically in Magento 2. It will be useful for you in your custom module or new feature.  In Magento 1, it’s quite simple using:

In Magento 2, we can use the following code: Define constructor

Use code … Continue reading Magento 2 clear – flush cache programmatically

Cache types in Magento 2

Published on

Cache types in Magento 2 – As we can see, there are 13 cache types in “System -> Cache Management”. In this post, let’s find out what they are used for and when we need to flush each type. 1. Configuration Code: config Description: Magento collects configuration from all modules, merges it, and saves the merged … Continue reading Cache types in Magento 2

Magento 2 get Base URL

Published on

Magento 2 get Base URL – As you know, in Magento 1 we can easily get base url using function:

In this tutorial, let’s find out how to get base url in Magento 2 In Magento 2, we can get base url using an instance of StoreManagerInterface  1. Create an instance of StoreManagerInterface in __construct … Continue reading Magento 2 get Base URL

Magento 2 Add a menu item in backend

Published on

In this blog post we will see how to add a menu item in backend for your Magento 2 module. 1. Create file VendorName/ModuleName/etc/menu.xml The admin menu in Magento 2 has 3 parts: The main admin menu title which shows up in left sidebar Submenu title Actual menu

2. Create file VendorName/ModuleName/etc/acl.xml

3. … Continue reading Magento 2 Add a menu item in backend