
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>
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.
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}`;