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 ElasticSearch: No alive nodes found in your cluster / Types cannot be provided in put mapping requests

Problem: There was the following error related to ElasticSearch / OpenSearch while reindexing the catalogsearch in Magento. bin/magento indexer:reindex catalogsearch_fulltext could not validate a connection to elasticsearch. no alive nodes found in your cluster Another similar error during catalogsearch reindex: bin/magento indexer:reindex catalogsearch_fulltext Catalog Search index process error during indexation process: {"error":{ "root_cause":[{ "type":"illegal_argument_exception", "reason":"Types … Read more

Set up Magento 2 Development Environment with Docker & Warden

Warden is a CLI utility for orchestrating Docker-based developer environments and enables multiple local environments to run simultaneously without port conflicts. docker-compose is used to control everything that Warden runs. Using Warden, a custom environment can be set up for each project. The environment can also be overridden or extended. Warden supports the following applications … Read more

Backup & Restore Magento2 Database using N98-magerun2

n98-magerun is a handy CLI tool to work on Magento from command line. Backup/Dump Database Backup Database in a plain SQL File n98-magerun2.phar db:dump var/projectName_date.sql Print only the MySQL command. Do not execute it. This can be done by using the –only-command option. n98-magerun2.phar db:dump –only-command var/projectName_date.sql You may also use the time command which … 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

Magento2: Reset Admin 2FA (Two-Factor Authentication)

This article shows how you can reset your Magento 2 Admin User’s 2FA (Two-Factor Authentication). Get your admin user ID from admin_user table. SELECT user_id from admin_user WHERE username = 'YOUR_ADMIN_USERNAME'; OR, SELECT user_id from admin_user WHERE email = 'YOUR_ADMIN_EMAIL'; For e.g. My admin user id = 299 username: MukeshChapagain Check two-factor authentication related table … Read more