magento2: Product grid is not getting displayed, getting undefined array key "name" in logs.
Preconditions and environment
- Magento 2.4.4
- Upgraded from M2.4.1
- PHP 8.1
Steps to reproduce
- Login as admin.
- Go to Store->attributes->product search code “name” and set Values Required to “NO”
- Create a product without name in 2.4.1 and then upgrade to 2.4.4 along with PHP.
- Now, create a Product without name after setting the ‘Name’ attribute as not mandatory.
Expected result
The Product Grid should load fine as usual.
Actual result
The Product Grid throws an alert of something went wrong and freezes.
Additional information
The Log shows the below error:
main.CRITICAL: Exception: Warning: Undefined array key "name" in /vendor/magento/module-catalog/Ui/Component/Listing/Columns/ProductActions.php on line 61 in /vendor/magento/framework/App/ErrorHandler.php:61
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 41 (4 by maintainers)
@RiccardoRoscilli Here is the query to find out products without name
SELECT sku,entity_id FROM
catalog_product_entityWHERE
entity_idNOT IN (SELECT
entity_idFROM
catalog_product_entity_varcharWHERE
attribute_idIN (SELECT attribute_id FROM
eav_attributeWHERE
attribute_code='name'))
After debugging a little bit, I have fixed the Grid issue. edit the file:
/vendor/magento/module-catalog/Ui/Component/Listing/Columns/ProductActions.php
and replaced the line 61 from:'ariaLabel' => __('Edit ') . $item['name'],
to'ariaLabel' => __('Edit ') . isset($item['name'])?$item['name']:'',
Reconfirming issue on 2.4.4 - Not sure why it has been able to save product entities without a name (title) set (on the base store view) but it happened. This is fully breaking the admin grid functionality, even in production, due to attempted rendering of an aria label. (So high impact for a ‘minor’ feature).
Fix as per comment https://github.com/magento/magento2/issues/35783#issuecomment-1189348535 is solid. Not sure why this low hanging fruit with high impact is on the low prio backlog. Will slam in a PR in a minute
✔️ Issue confirmed
Issue got reproduced in 2.4-develop branch.
Description: Product grid is not displayed in the admin panel.
Pre-requisite:
Steps to reproduce:
Expected result: Grid should be displayed. Actual result: In my case, grid is not visible and getting error in the admin panel. Screenshots:
Found new issue related to this issue : https://github.com/magento/magento2/issues/35789 Hence, confirming this issue.
Thanks
This error has also occurred for us when using the native product import - the default amount of errors is set to 10 for some reason, so you can import products with no name.
I was using Magento 2.4.6 + PHP 8.2 on production environment and had a cron job running every midnight to scrape and automatically update product information. However, this morning when I checked the admin page, the product grid was not showing up. and fortunately, I found the cause.
The product with SKU value “K00001” was originally an existing product. However, seeing that a new SKU “K00001-1” was created, it seems that during the scraping of product information, there was a duplication of the URL key, causing Magento to mistakenly create an empty product.
Not only the “name” attribute, but other attributes used in the product were also empty. Therefore, I simply deleted the product using the “delete from ~” query, and the grid displayed correctly on the admin page.
It’s been a few months, and it happened again, so I came back here after searching on Google. In my case, this error occasionally occurs when I scrap the product, perform automatic translation, and upload the content.
This worked great for me. Found 6 products and then ran an import on those products to add a name/Product Name and that sorted the issue.
This could happen when there is any product stored without required attribute “name” and either you can add name value or remove that bad created product.