Magento 2 API: Get Categories

In this article, we will be looking into how we can get the Categories in Magento 2 using its API. Get All Categories Get Category by category id Search Categories Anonymouse APIs Restriction The REST endpoints to get the stores’ information falls under the anonymous APIs category. However, in the recent Magento version, those API … Read more

Magento 2: Clean Cache by Cache Tags Programmatically

This article shows how you can clean cache by cache tags in Magento. use Magento\Framework\App\CacheInterface; class YourClassName { /** * @var CacheInterface */ protected $cache; /** … * @param CacheInterface $cache */ public function __construct( … CacheInterface $cache ) { … $this->cache = $cache; } /** * Clean Cache by Cache Tag * * @param … Read more

Magento 2: Useful Configuration Settings & CLI Commands for Development Environment

This article shows some of the configuration settings and CLI commands that are useful for developers in their development environment. For example, enabling logging, enabling template path hints, disabling forced admin password change, etc. Disable password change From Magento admin Stores > Configuration > Advanced > Admin > Password Lifetime(days) = 0 Stores > Configuration … Read more

Magento 2: Enable Template Path & Block Class Hints

Template path hints and Block class hints are very useful features for debugging purposes in Magento. This feature helps you to know which template file is being used in any of the Magento pages. For example, third-party modules can override core template files of any page or any section like header, footer, etc. The template … Read more

Magento 2: Enable Database/MySQL Query Log

MySQL database query logging can be enabled/disabled from command line. This will help in debugging database queries. Enable database query logging The following CLI command enabled database/mysql query log: bin/magento dev:query-log:enable Flush cache bin/magento cache:flush After that, browse your Magento site. The database queries logs are saved in the file var/debug/db.log. Note: The database query … Read more

Magento2 – Encrypt & Decrypt Configuration Settings Value using N98-magerun2 CLI

This article shows how you can encrypt and decrypt Magento configuration settings values using the n98-magerun2 command line (CLI) tool. Get configuration settings value in plain text n98-magerun2.phar config:store:get path/of/config/setting Get configuration settings value on store level n98-magerun2.phar config:store:get –scope=stores –scope-id=2 config/setting/path Get decrypted configuration settings value n98-magerun2.phar config:store:get –decrypt config/setting/path Set configuration settings value … Read more

Magent 2: Load Configurable Product with Options pre-selected

This article shows how you can load any configurable product in Magento with the configurable options pre-selected. We can append the Attribute-OptionValue hash value (#Attribute_ID=Value_ID) at the end of the configurable product URL. For example, let’s suppose that the configurable product URL is: https://example.com/my-configurable-product.html We can add the attribute option values like this: https://example.com/my-configurable-product.html#802=130&805=187 #Attribute_ID=Value_ID … Read more

Magento 2: Add Custom Console CLI Command in your Module

Magento allows to create custom console commands to the Symfony-like command-line interface (CLI). The Console component allows you to create command-line commands. You can create custom console commands for any task like import, export, or other batch jobs. In this article, I will be creating a custom Magento2 module and will add a custom console … Read more

Magento 2: Disable Admin Password Expiration/Change

Magento’s backend/admin password expires in 90 days by default. So, in every 90 days, when you login to admin, you will be asked to change your admin user’s password. This is a useful security feature in production/live site. However, this can be annoying to have in a development/testing site. This article shows on how you … Read more