Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to load value of nonexistent EAV attribute #598

Closed
csdougliss opened this issue Oct 5, 2018 · 41 comments
Closed

Attempt to load value of nonexistent EAV attribute #598

csdougliss opened this issue Oct 5, 2018 · 41 comments

Comments

@csdougliss
Copy link

csdougliss commented Oct 5, 2018

Preconditions

  1. Magento 1 EE 1.14.3.10
  2. Magento 2 EE 2.2.6
  3. PHP 7.1.22
  4. MySQL 5.7.23

Steps to reproduce

  1. Migrate data from Magento 1 to 2
  2. View a product page

Expected result

  1. No error. This error started to occur in Magento EE 2.2.6.

Actual result

  1. Errors in system.log and support_report.log
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '83' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '169' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '501' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '167' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '215' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '220' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '223' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '395' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '402' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '417' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '451' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '452' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:52] report.WARNING: Attempt to load value of nonexistent EAV attribute '551' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '83' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '438' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '167' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '215' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '220' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '221' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '222' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '223' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '269' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '332' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '395' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '402' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '417' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '451' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '452' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-10-05 12:40:53] report.WARNING: Attempt to load value of nonexistent EAV attribute '470' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
  1. But these attributes do in fact exist, for example eav_attribute 83
SELECT attribute_id, entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note
FROM magento2_prod.eav_attribute
WHERE attribute_id=83;```

attribute_id entity_type_id attribute_code attribute_model backend_model backend_type backend_table frontend_model frontend_input frontend_label frontend_class source_model is_required is_user_defined default_value is_unique note
83 4 color [NULL] [NULL] int [NULL] [NULL] select Color [NULL] [NULL] 0 1 [NULL] 0 [NULL]

@gewaechshaus
Copy link

gewaechshaus commented Oct 15, 2018

@craigcarnell - Same here with CE 2.2.6, investigating...

@victor-v-rad
Copy link
Collaborator

Hi @craigcarnell

Thank you for reporting the issue. Internal ticket MAGETWO-95789 to investigate and fix it

@mhauri
Copy link

mhauri commented Oct 24, 2018

Same issue with Magento Open Source 2.2.6 with migrated data.

@csdougliss
Copy link
Author

@victor-v-rad any update on this issue?

@victor-v-rad
Copy link
Collaborator

Not yet. Does it create any issues apart from the warning message in system.log file?

@csdougliss
Copy link
Author

@victor-v-rad no just system.log writes

@victor-v-rad
Copy link
Collaborator

victor-v-rad commented Nov 7, 2018

This issue is created on the M1 side. When in M1 > admin panel > some product has value set for its custom attribute and you remove this attribute from attribute group, then M1 do not clean the value you set for the product. It should remove record from from catalog_product_entity_int)
Hotfix can be removing those records by SQL query

@csdougliss
Copy link
Author

@victor-v-rad In M1 DB I have run:

https://gist.github.com/dfelton/042e15a51b9795b25cad0235a1bf9122#file-magento-ee-1-14-2-0-sql

I have then created a new DB.

However, I still get the following:

[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '219' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '223' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '225' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '332' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '83' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '438' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '501' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '395' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '551' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '253' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '414' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '219' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '223' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '225' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '332' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '83' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []
[2018-11-07 11:08:44] report.WARNING: Attempt to load value of nonexistent EAV attribute '438' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []

Is there any other SQL I need to run?

@victor-v-rad
Copy link
Collaborator

I do not have this SQL. The issue will be fixed in according ticket

@csdougliss
Copy link
Author

csdougliss commented Nov 14, 2018

@victor-v-rad:

In my m2 DB:

I've checked eav_attribute for 83 which is color.
It's not assigned any attribute sets.
But there is still values in catalog_product_entity_int.

This is some clean up SQL that I found:

DELETE FROM catalog_product_entity_int 
    WHERE value_id IN 
        (SELECT cpei.value_id 
            FROM catalog_product_entity_int cpei 
            WHERE cpei.attribute_id NOT IN 
                (SELECT eea.attribute_id 
                    FROM eav_entity_attribute eea 
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id 
                    WHERE cpe.entity_id = cpei.row_id) 
        ORDER BY cpei.attribute_id);

Is this correct?

I do however, get this error message when a eav_attribute is still in a set. For example, eav attribute 395 is in 7 attribute sets but it still included in the error message.

[2018-11-14 14:20:31] report.WARNING: Attempt to load value of nonexistent EAV attribute '395' 
                        for entity type 'Magento\Catalog\Api\Data\ProductInterface'. [] []

@victor-v-rad
Copy link
Collaborator

@craigcarnell

Color has Dropdown input type, hence its values stores in catalog_product_entity_int. But there are many other attributes with other input types, which can store their values in catalog_product_entity_varchar, catalog_product_entity_text, catalog_product_entity_decimal, etc.

@csdougliss
Copy link
Author

@victor-v-rad Is it safe to delete this data in this case, for example - color where the data is not used?

@victor-v-rad
Copy link
Collaborator

In M2 if you unassign some attribute from an attribute group the values in catalog_product_entity_* tables are cleaned up accordingly. So it should be safe to delete it by SQL query. One more way to delete these values is in Admin Panel assign and unassign these problematic attributes from existing attribute group and Magento should clean catalog_product_entity_* tables

@csdougliss
Copy link
Author

I hope this is useful to somebody, but this is what I'm using on M1:

CREATE TABLE catalog_product_entity_int_old LIKE catalog_product_entity_int;
INSERT INTO catalog_product_entity_int_old SELECT * FROM catalog_product_entity_int;

DELETE FROM catalog_product_entity_int 
    WHERE value_id IN 
        (SELECT cpei.value_id 
            FROM catalog_product_entity_int_old cpei 
            WHERE cpei.attribute_id NOT IN 
                (SELECT eea.attribute_id 
                    FROM eav_entity_attribute eea 
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id 
                    WHERE cpe.entity_id = cpei.entity_id) 
        ORDER BY cpei.entity_id);
DROP TABLE catalog_product_entity_int_old; 

CREATE TABLE catalog_product_entity_text_old LIKE catalog_product_entity_text;
INSERT INTO catalog_product_entity_text_old SELECT * FROM catalog_product_entity_text;

DELETE FROM catalog_product_entity_text 
    WHERE value_id IN 
        (SELECT cpei.value_id 
            FROM catalog_product_entity_text_old cpei 
            WHERE cpei.attribute_id NOT IN 
                (SELECT eea.attribute_id 
                    FROM eav_entity_attribute eea 
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id 
                    WHERE cpe.entity_id = cpei.entity_id) 
        ORDER BY cpei.entity_id);
DROP TABLE catalog_product_entity_text_old;

CREATE TABLE catalog_product_entity_varchar_old LIKE catalog_product_entity_varchar;
INSERT INTO catalog_product_entity_varchar_old SELECT * FROM catalog_product_entity_varchar;

DELETE FROM catalog_product_entity_varchar 
    WHERE value_id IN 
        (SELECT cpei.value_id 
            FROM catalog_product_entity_varchar_old cpei 
            WHERE cpei.attribute_id NOT IN 
                (SELECT eea.attribute_id 
                    FROM eav_entity_attribute eea 
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id 
                    WHERE cpe.entity_id = cpei.entity_id) 
        ORDER BY cpei.entity_id);
DROP TABLE catalog_product_entity_varchar_old;

@csdougliss
Copy link
Author

The above SQL worked for me, going to close this ticket for now.

@csdougliss
Copy link
Author

Re opened as my sql didn't fix everything it would seem

@adamrandazzo
Copy link

Just to add -- I started noticing this when I just upgraded to 2.2.6 and my system.log and support_report.log started growing exponentially. Each log file was 7GB within 12 hours of a logrotate.

Is it possible the upgrade to 2.2.6 added a bunch of unnecessary data?

@JamesAllwood
Copy link

These seem to regenerate after moving a product to a new attribute set in the admin. So, that would indicate that Magento isn't cleaning up after itself either, removing orphan values when no longer part of the current attribute set.

This appears to create a considerable slowdown in the process of saving products.

Cleaning the orphans results in an increase in admin speed.

@csdougliss
Copy link
Author

@victor-v-rad Any updates on this issue?

@mcspronko
Copy link

We are having the issue on Magento Open Source 2.2.7 as well.

@Zyles
Copy link

Zyles commented Feb 23, 2019

Same with 2.3.0.

@ladle3000
Copy link

Same 2.3.0

@ladle3000
Copy link

@JamesAllwood in what way are you cleaning the orphan values?

@csdougliss
Copy link
Author

csdougliss commented Mar 7, 2019

Hi all,

This is what I'm using on M2. It's very similar to the above on M1. I'm not sure why it is required, as this data has already been "cleansed" in M1 before migration?

I have not edited or changed anything in M2 post migration with this one.

Do not try this on live..

CREATE TABLE catalog_product_entity_int_old LIKE catalog_product_entity_int;
INSERT INTO catalog_product_entity_int_old SELECT * FROM catalog_product_entity_int;

DELETE FROM catalog_product_entity_int
    WHERE value_id IN
        (SELECT cpei.value_id
            FROM catalog_product_entity_int_old cpei
            WHERE cpei.attribute_id NOT IN
                (SELECT eea.attribute_id
                    FROM eav_entity_attribute eea
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id
                    WHERE cpe.row_id = cpei.row_id)
        ORDER BY cpei.row_id);
DROP TABLE catalog_product_entity_int_old;

CREATE TABLE catalog_product_entity_text_old LIKE catalog_product_entity_text;
INSERT INTO catalog_product_entity_text_old SELECT * FROM catalog_product_entity_text;

DELETE FROM catalog_product_entity_text
    WHERE value_id IN
        (SELECT cpei.value_id
            FROM catalog_product_entity_text_old cpei
            WHERE cpei.attribute_id NOT IN
                (SELECT eea.attribute_id
                    FROM eav_entity_attribute eea
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id
                    WHERE cpe.row_id = cpei.row_id)
        ORDER BY cpei.row_id);
DROP TABLE catalog_product_entity_text_old;

CREATE TABLE catalog_product_entity_varchar_old LIKE catalog_product_entity_varchar;
INSERT INTO catalog_product_entity_varchar_old SELECT * FROM catalog_product_entity_varchar;

DELETE FROM catalog_product_entity_varchar
    WHERE value_id IN
        (SELECT cpei.value_id
            FROM catalog_product_entity_varchar_old cpei
            WHERE cpei.attribute_id NOT IN
                (SELECT eea.attribute_id
                    FROM eav_entity_attribute eea
                        JOIN catalog_product_entity cpe ON eea.attribute_set_id = cpe.attribute_set_id
                    WHERE cpe.row_id = cpei.row_id)
        ORDER BY cpei.row_id);
DROP TABLE catalog_product_entity_varchar_old;

@JamesAllwood
Copy link

@snoroozi yes, I have a few queries that do the trick for me. Use at your own risk, and it goes without saying, only use if you have a backup available (also, don't judge me on the sql, I'm sure there's better ways to have written it). These handle values from products and categories, as I found issues there too:

DELETE
	catalog_category_entity_int.*
FROM
	catalog_category_entity_int
JOIN
	catalog_category_entity ON
    catalog_category_entity_int.entity_id = catalog_category_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_category_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_category_entity_int.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_category_entity_varchar.*
FROM
	catalog_category_entity_varchar
JOIN
	catalog_category_entity ON
    catalog_category_entity_varchar.entity_id = catalog_category_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_category_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_category_entity_varchar.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_category_entity_text.*
FROM
	catalog_category_entity_text
JOIN
	catalog_category_entity ON
    catalog_category_entity_text.entity_id = catalog_category_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_category_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_category_entity_text.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_category_entity_decimal.*
FROM
	catalog_category_entity_decimal
JOIN
	catalog_category_entity ON
    catalog_category_entity_decimal.entity_id = catalog_category_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_category_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_category_entity_decimal.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_product_entity_int.*
FROM
	catalog_product_entity_int
JOIN
	catalog_product_entity ON
    catalog_product_entity_int.entity_id = catalog_product_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_product_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_product_entity_int.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_product_entity_varchar.*
FROM
	catalog_product_entity_varchar
JOIN
	catalog_product_entity ON
    catalog_product_entity_varchar.entity_id = catalog_product_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_product_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_product_entity_varchar.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_product_entity_text.*
FROM
	catalog_product_entity_text
JOIN
	catalog_product_entity ON
    catalog_product_entity_text.entity_id = catalog_product_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_product_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_product_entity_text.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;

DELETE
	catalog_product_entity_decimal.*
FROM
	catalog_product_entity_decimal
JOIN
	catalog_product_entity ON
    catalog_product_entity_decimal.entity_id = catalog_product_entity.entity_id
LEFT JOIN
	eav_entity_attribute ON
    (
        catalog_product_entity.attribute_set_id = eav_entity_attribute.attribute_set_id
        AND
        catalog_product_entity_decimal.attribute_id = eav_entity_attribute.attribute_id
    )  
WHERE
	eav_entity_attribute.entity_attribute_id IS NULL;
	
DELETE 
	catalog_product_entity_datetime.* 
FROM
	catalog_product_entity_datetime
LEFT JOIN
	eav_attribute ON
    catalog_product_entity_datetime.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_product_entity_decimal.* 
FROM
	catalog_product_entity_decimal
LEFT JOIN
	eav_attribute ON
    catalog_product_entity_decimal.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_product_entity_int.* 
FROM
	catalog_product_entity_int
LEFT JOIN
	eav_attribute ON
    catalog_product_entity_int.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_product_entity_text.* 
FROM
	catalog_product_entity_text
LEFT JOIN
	eav_attribute ON
    catalog_product_entity_text.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_product_entity_varchar.* 
FROM
	catalog_product_entity_varchar
LEFT JOIN
	eav_attribute ON
    catalog_product_entity_varchar.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_category_entity_datetime.* 
FROM
	catalog_category_entity_datetime
LEFT JOIN
	eav_attribute ON
    catalog_category_entity_datetime.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_category_entity_decimal.* 
FROM
	catalog_category_entity_decimal
LEFT JOIN
	eav_attribute ON
    catalog_category_entity_decimal.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_category_entity_int.* 
FROM
	catalog_category_entity_int
LEFT JOIN
	eav_attribute ON
    catalog_category_entity_int.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_category_entity_text.* 
FROM
	catalog_category_entity_text
LEFT JOIN
	eav_attribute ON
    catalog_category_entity_text.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;

DELETE 
	catalog_category_entity_varchar.* 
FROM
	catalog_category_entity_varchar
LEFT JOIN
	eav_attribute ON
    catalog_category_entity_varchar.attribute_id = eav_attribute.attribute_id
WHERE
	eav_attribute.attribute_id IS NULL;	

@ladle3000
Copy link

@JamesAllwood Thanks for sharing. Have you noticed any ill effects from doing these? Usually you fix one thing you break another you know?

@victor-v-rad do you have any update on official magento fixes for this issue?

@victor-v-rad
Copy link
Collaborator

Hi @snoroozi
Not yet, but the tool is open for your contribution

@ladle3000
Copy link

ladle3000 commented Mar 7, 2019 via email

@haxim0r
Copy link

haxim0r commented Mar 20, 2019

Magento 2.3.0 CE -> Have you checked if the attribute in question has been added to the product attribute_set list?
Clear Magento Cache before checking fix and bashing me, please =)

@ladle3000
Copy link

this is a post migration problem

@emadof85
Copy link

just try to check hidden files with . prefix owner to be magento owner, it worked for me since the upgrade process will reset everything to default

@ladle3000
Copy link

@emadof85 who are you replying to and what are you talking about exactly?

@divyeshmehta820
Copy link

i am having same issue in Magento 2.2.6, is there any solution exist ?

@ebofi
Copy link

ebofi commented Apr 11, 2019

same with magento 2.2.7

@coresh
Copy link

coresh commented Apr 12, 2019

same with magento 2.2.8

@ioweb-gr
Copy link

I would like to mention that I'm facing the same issue. I've migrated from 1.7 though but the issue is the same and is happening in not only products but categories as well. This issue does have a performance impact when saving products or categories when throwing these warnings. Instead of taking very little time to save, it takes significant more time while looking up missing attributes.

@waldok
Copy link

waldok commented Apr 17, 2019

Is there any well proven solution to this problem?

@victortodoran
Copy link

victortodoran commented Apr 19, 2019

In M 2.2.8 the issue is caused by the way the Magento\Eav\Model\ResourceModel\ReadHandler is populating eav_entities. The log message is misleading. For the sake of simplicity I will talk about the product entity.

The ReadHandler loads all the attribute codes and ids associated with the entity based on the corresponding attribute set.

  foreach ($this->getEntityAttributes($entityType, new DataObject($entityData)) as $attribute) {
            if (!$attribute->isStatic()) {
                $attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId();
                $attributesMap[$attribute->getAttributeId()] = $attribute->getAttributeCode();
            }
        }

It then loads all the values from all value tables(catalog_product_entity_varchar|int|etc).
It then uses the attributesMap to map each value to an attribute code.

Each time an attribute value is found that does not have a corespondent in the $attributesMap it logs this message.

 foreach ($connection->fetchAll($unionSelect) as $attributeValue) {
                if (isset($attributesMap[$attributeValue['attribute_id']])) {
                    $entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
                } else {
                    $this->logger->warning(
                        "Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}' 
                        for entity type '$entityType'."
                    );
                }
            }

Each time a there is a value on an entity in one of the value tables, that is not in the current used attribute set on that entity, this message will be logged.

There are a couple of options, I'll present two. Both should be approached carefully.

  1. You remove all unused data.
  2. You change the logic of this class and remove the log.

As is, I don't think this is a data_migration_tool (just an opinion) but rather a bizarre way of populating eav entities. The log message is wrong 100% as the attribute might very well exist.

I'm pretty sure this logic was not in all 2.2.x versions as I only started seeing the logs after I upgraded from 2.2.3 -> 2.2.8.

@AndyJAllen
Copy link

AndyJAllen commented May 8, 2019

In M 2.2.8 the issue is caused by the way the Magento\Eav\Model\ResourceModel\ReadHandler is populating eav_entities. The log message is misleading. For the sake of simplicity I will talk about the product entity.

The ReadHandler loads all the attribute codes and ids associated with the entity based on the corresponding attribute set.

  foreach ($this->getEntityAttributes($entityType, new DataObject($entityData)) as $attribute) {
            if (!$attribute->isStatic()) {
                $attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId();
                $attributesMap[$attribute->getAttributeId()] = $attribute->getAttributeCode();
            }
        }

It then loads all the values from all value tables(catalog_product_entity_varchar|int|etc).
It then uses the attributesMap to map each value to an attribute code.

Each time an attribute value is found that does not have a corespondent in the $attributesMap it logs this message.

 foreach ($connection->fetchAll($unionSelect) as $attributeValue) {
                if (isset($attributesMap[$attributeValue['attribute_id']])) {
                    $entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
                } else {
                    $this->logger->warning(
                        "Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}' 
                        for entity type '$entityType'."
                    );
                }
            }

Each time a there is a value on an entity in one of the value tables, that is not in the current used attribute set on that entity, this message will be logged.

There are a couple of options, I'll present two. Both should be approached carefully.

1. You remove all unused data.

2. You change the logic of this class and remove the log.

As is, I don't think this is a data_migration_tool (just an opinion) but rather a bizarre way of populating eav entities. The log message is wrong 100% as the attribute might very well exist.

I'm pretty sure this logic was not in all 2.2.x versions as I only started seeing the logs after I upgraded from 2.2.3 -> 2.2.8.

This is more pertinent to my situation since I only ever upgraded from 2.1.8 to 2.2.6; and referenced attributes in the log do exist so the warning was very confusing for me. For me it references the same attributes constantly (114 - country_of_manufacture & 184 - a custom one I created).

It looks like there was attention given to this issue on GitHub for ReadHandler.php:
magento/magento2@ab27445

victor-v-rad added a commit that referenced this issue May 15, 2019
@victor-v-rad
Copy link
Collaborator

Fixed in c5d7b65

@csdougliss
Copy link
Author

@victor-v-rad Thanks 👍 Now migrated onto m2. Not seeing this after running the SQL I mentioned above on M1 followed by M2 cleanup.

Feel free to re-open if anyone else needs it.

victor-v-rad added a commit that referenced this issue May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests