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

  1. Login as admin.
  2. Go to Store->attributes->product search code “name” and set Values Required to “NO”
  3. Create a product without name in 2.4.1 and then upgrade to 2.4.4 along with PHP.
  4. 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)

Commits related to this issue

Most upvoted comments

@RiccardoRoscilli Here is the query to find out products without name

SELECT sku,entity_id FROM catalog_product_entityWHEREentity_idNOT IN (SELECTentity_idFROMcatalog_product_entity_varcharWHEREattribute_idIN (SELECT attribute_id FROMeav_attributeWHEREattribute_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:

  1. Install fresh M 2.4.1
  2. Upgrade to latest version.
  3. PHP 8.1

Steps to reproduce:

  1. Install 2.4.1.
  2. Login as admin.
  3. Go to Store->attributes->product search code “name” and set Values Required to “NO”
  4. Create a product without name in 2.4.1 and then upgrade to latest version of Magento along with PHP.
  5. Now, create a Product without name after setting the ‘Name’ attribute as not mandatory.

Expected result: Grid should be displayed. Actual result: In my case, grid is not visible and getting error in the admin panel. Screenshots: Screenshot from 2022-07-21 12-47-06

Screenshot from 2022-07-21 12-42-11

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.

@RiccardoRoscilli다음은 이름이 없는 제품을 찾는 쿼리입니다.

SELECT sku,entity_id FROM catalog_product_entity WHEREentity_id NOT IN (SELECTentity_id FROMcatalog_product_entity_varchar WHEREattribute_id IN (SELECT attribute_id FROMeav_attribute WHEREattribute_code='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.

SELECT entity_id, sku FROM catalog_product_entity A WHERE NOT EXISTS (
	SELECT 'x' 
	FROM catalog_product_entity_varchar B, eav_attribute C
	WHERE A.entity_id=B.entity_id AND B.attribute_id=C.attribute_id AND C.attribute_code='name'
) 
entity_id  sku     
---------  --------
    24436  K08187  
<?php
require '/var/www/magento/app/bootstrap.php';
$bootstrap = Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objectManager->get('Magento\Framework\App\State')->setAreaCode(Magento\Framework\App\Area::AREA_ADMINHTML);
$objectManager->get('\Magento\Store\Model\StoreManagerInterface')->setCurrentStore(0);
$objectManager->get('Magento\Framework\Registry')->register('isSecureArea', true);

$productCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
$productCollection->addAttributeToSelect('*')->addFieldToFilter('entity_id', ['eq' => 24436])
    ->addAttributeToSort('entity_id', 'ASC');
foreach($productCollection as $prod) {
    print_r($prod->getData());
}
Array
(
    [entity_id] => 24436
    [attribute_set_id] => 11
    [type_id] => simple
    [sku] => K08187
    [has_options] => 0
    [required_options] => 0
    [created_at] => 2023-08-09 22:11:09
    [updated_at] => 2023-08-09 22:11:09
    [meta_title] => Experience this oneElegance with 
    [meta_description] => Immerse this on
    [image] => /-/f/-fu-0.jpg
    [small_image] => /-/f/-fu-0.jpg
    [thumbnail] => /-/f/-fu-0.jpg
    [options_container] => container2
    [image_label] =>  #0
    [small_image_label] =>  #0
    [thumbnail_label] =>  #0
    [url_key] => fu
    [msrp_display_actual_price_type] => 0
    [sourcing_product_id] => 2970736
    [cost_price] => 0
    [news_from_date] => 2023-08-09 00:00:00
    [news_to_date] => 2023-08-23 00:00:00
    [status] => 0
    [visibility] => 4
    [quantity_and_stock_status] => 1
    [tax_class_id] => 0
    [pre_order] => 0
    [limited_edition] => 0
    [ox_featured] => 0
    [ox_gallery_video_index] => 2
    [ox_gallery_video_listing_hover] => 0
    [ox_gallery_video_stop_on_click] => 1
    [ox_gallery_video_autoplay] => 1
    [ox_gallery_video_loop] => 1
    [ox_gallery_video_controls] => 0
    [ox_custom] => 0
    [goods_type] => 8688
    [price] => 0.000000
    [weight] => 0.000000
    [language_edition] => 6101
    [store_id] => 0
)
/* Delete the record (catalog_product_entity T/B) with entity_id */
DELETE FROM catalog_product_entity WHERE entity_id=24436

SELECT sku,entity_id FROM catalog_product_entityWHEREentity_idNOT IN (SELECTentity_idFROMcatalog_product_entity_varcharWHEREattribute_idIN (SELECT attribute_id FROMeav_attributeWHEREattribute_code='name'))

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.