This article provides answers to questions about the most common and less known bugs that you may encounter while developing for Magento 2. The developer experience is improving with every release. Yet, there are many error messages that are cryptic, mysterious and unclear.
Whether you're a seasoned developer or just starting out, this guide lists ready-made solutions to fix issues with Magento 2 and keep your projects running smoothly.
This guide is a living document and is constantly updated.
Missing di.xml configuration argument
When happens:
- bin/magento setup:upgrade
- bin/magento setup:di:compile
Notice: Undefined index: value in /var/www/html/vendor/magento/framework/Data/Argument/Interpreter/DataObject.php on line 37
Solution to Undefined index: value
Check for missing item config in the module di.xml file. Example of invalid Magento 2 configuration:
<type name="Magento\Framework\Console\CommandListInterface">
<arguments>
<argument name="commands" xsi:type="array">
<item name="lucid-modules-kustom-command" xsi:type="object"></item>
</argument>
</arguments>
</type>
As you might have noticed, the XML node lucid-modules-kustom-command
is empty.
Provide a fully qualified name to the class that should be injected as the object parameter.
Admin grid not sorting entries
If admin grid is not sorting properly and displays all the same records, then chances are you have not configured the index field in the <storageConfig>
node:
Solution to Magento 2 sorting not working correctly for custom admin grid
Open the grid component XML definition located in your module, e.g:
view/adminhtml/ui_component/{GRID_COMPONENT_NAME}_listing.xml
Configure the index field value with column name that is the primary field in your table:
<dataSource name="vendor_module_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<updateUrl path="mui/index/render" />
<storageConfig>
<param name="indexField" xsi:type="string">entity_id</param>
</storageConfig>
</settings>
<!-- Other entries -->
</dataSource>
Index catalog_product not reindexed
This can happen when you delete all indices from ElasticSearch / OpenSearch or when you've launched a fresh instance:
Exception #0 (LogicException): catalog_product index does not exist yet. Make sure everything is reindexed.
Solution to index catalog_product not exist
Being on the faulty machine, run the reindex process with CLI command:
bin/magento index:reindex
Unsupported ElasticSearch or OpenSearch version
After indexing a fresh Magento installation with bin/magento index:reindex
you encounter a following error:
bin/magento index:reindex
...
Catalog Search index process unknown error:
{"error":"no handler found for uri [/magento2_product_1_v1/document/_mapping] and method [PUT]"}
Solution to Magento 2 "no handler found for uri" error
Magento 2.4.5 and previous versions do not support ElasticSearch 8 and OpenSearch 2.
Downgrade ElasticSearch to version 7.*
or switch OpenSearch to version 1.*
.
Magento 2 cluster block exception on reindex
When you execute Magento upgrade or reindex commands, you might get an error: cluster_block_exception [TOO_MANY_REQUESTS]
.
ElasticSearch or OpenSearch may return trace similar to the following:
{
"error": {
"root_cause": [
{
"type": "cluster_block_exception",
"reason": "index [magento2_product_2_v1090] blocked by: [TOO_MANY_REQUESTS/12/index read-only / allow delete (api)];"
}
],
"type": "cluster_block_exception",
"reason": "index [magento2_product_2_v1090] blocked by: [TOO_MANY_REQUESTS/12/index read-only / allow delete (api)];"
},
"status": 429
}
Solution to Magento 2 cluster block exception
Free ElasticSearch instance disk space or disable the allocation threshold with curl request.
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
Magento 2 theme is not displayed
You develop for Magento 2 on local environment and theme is not displayed.
This might be caused by running bin/magento setup:upgrade
before you have downloaded theme files.
Solution to invisible Magento 2 theme
Update the type
column to 0
in Magento 2 theme
table .
Import fails with Error in data structure: entity values are mixed
This issue arises after Magento 2 fails during the import process.
Magento 2 keeps imported rows in importexport_importdata
table to ensure unique ID for each row.
Solution to Magento 2 Error in data structure
Get rid of stale import data and truncate the table importexport_importdata
using the following SQL command:
TRUNCATE importexport_importdata;
Remember to add an appropriate prefix if your database tables have one.
You do not have the SUPER privilege and binary logging is enabled
This error can happen during bin/magento setup:upgrade
.
The full error message:
SQLSTATE[HY000]: General error: 1419 You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable), query was: DROP TRIGGER IF EXISTS `trg_catalog_category_entity_after_insert`
Solution to failure during trigger drop
Enable log_bin_trust_function_creators in your database parameters:
log_bin_trust_function_creators = 1
This is how it looks in the AWS RDS dashboard:
Error in Magento cron.log: No callbacks found for cron job example_cron_job_name
This error occurs when you uninstall a module or remove configuration to a previously available cron job.
Example Magento 2 configuration for crontab.xml
:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job name="example_cron_job_name" instance="Vendor\Module\Cron\SampleCron" method="execute">
<config_path>crontab/default/jobs/example_cron_job_name/schedule/cron_expr</config_path>
</job>
</group>
</config>
Solution to No callbacks found for cron job
Find configurations for the removed cron job:
SELECT config_id, path FROM core_config_data WHERE path LIKE '%example_cron_job_name%';
and delete IDs retrieved from the previous query:
DELETE FROM core_config_data WHERE config_id = `{id_from_the_select}`;
Magento jQuery Ui deprecations
Fallback to JQueryUI Compat activated.
Your store is missing a dependency for a jQueryUI widget.
Identifying and addressing the dependency will drastically improve the performance of your site.
This console warning is caused by requesting jquery/ui
instead of the respective UI module:
define([
'jquery/ui',
],
Magento 2 has split the monolithic jquery/ui
into separate modules for better performance and reduced JS code size of UI Components. However, to stay backwards compatible, the compat.js
file is loading all Ui modules in case of legacy code that is still requesting the whole jquery/ui
module.
Solution to jquery/ui compatibility
Search for all places using jquery/ui
in your codebase and themes. Update the required modules with their respective equivalents. You can find the appropriate module by its function name in Magento 2 vendor/module-ui
directory. For example: jquery-ui-modules/widget
.