MySQL: Drop All Triggers from a Database

I got the error “Trigger already exists” error while I was re-importing a MySQL database. A solution to this problem is to create DROP queries for all the Triggers of the database. SELECT Concat('DROP TRIGGER ', Trigger_Name, ';') FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = 'your_database_name'; This will print out the DROP statements for all the triggers. … 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 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