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

Catalog Search index process unknown error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.store_id' in 'field list', query was: SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_id FROM customer_entity_varchar AS t.... #842

Open
ghost opened this issue Sep 10, 2020 · 8 comments

Comments

@ghost
Copy link

ghost commented Sep 10, 2020

Preconditions

  1. Migrating from Magento 1.9.4.5
  2. Migrating to Magento 2.4.0

Steps to reproduce

  1. Setup clean installation of Magento 2.4.0
  2. Run Settings migration as usual
  3. Run Data migration as usual
  4. Perform reindexing

Expected result

  1. Successfully rebuilt Catalog Search index.

Actual result

Catalog Search index process unknown error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.store_id' in 'field list', query was: SELECT u.* FROM ( (SELECT t.value, t.attribute_id, t.store_idFROMcustomer_entity_varcharASt WHERE (entity_id = '3') AND (attribute_id IN ('111', '479', '113', '114', '118', '563', '533', '514', '927', '982')) AND (store_idIN ('2', 0)))UNION ALL(SELECTt.value, t.attribute_id, t.store_idFROMcustomer_entity_intASt WHERE (entity_id = '3') AND (attribute_id IN ('119', '940', '941', '937', '117', '120')) AND (store_idIN ('2', 0)))UNION ALL(SELECTt.value, t.attribute_id, t.store_idFROMcustomer_entity_textASt WHERE (entity_id = '3') AND (attribute_id IN ('112', '115', '116', '121', '122', '123', '926', '530')) AND (store_idIN ('2', 0)))UNION ALL(SELECTt.value, t.attribute_id, t.store_idFROMcatalog_category_entity_varcharASt WHERE (entity_id = '3') AND (attribute_id IN ('965')) AND (store_idIN ('2', 0)))UNION ALL(SELECTt.value, t.attribute_id, t.store_idFROMcustomer_entity_datetimeASt WHERE (entity_id = '3') AND (attribute_id IN ('565', '566')) AND (store_idIN ('2', 0)))UNION ALL(SELECTt.value, t.attribute_id, t.store_idFROMcustomer_entity_decimalASt WHERE (entity_id = '3') AND (attribute_id IN ('942')) AND (store_idIN ('2', 0))) ) ASuORDER BYstore_id ASC

Additional notes

I managed to migrate both Settings and data successfully to a freshly installed magento 2.4.0 project.
My orders, products, settings etc .. where successfully migrated ( i am able to see them in backend )
But when i run the command php bin/magento indexer:reindex after successful migration, it shows this sql error.

This same sql error is shown when i take the category menu in backend admin panel.

I checked in my old magento 1.9.4.5 site, there also store_id column is not present in customer_entity_varchar table, but everything is working perfectly there.

Tried migrating data again in a freshly installed magento 2.4.0 agian, but no luck.

@m2-assistant
Copy link

m2-assistant bot commented Sep 10, 2020

Hi @iamprasanthmp. Thank you for your report.
To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


@m2-assistant
Copy link

m2-assistant bot commented Sep 11, 2020

Hi @iamprasanthmp! 👋
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

@m2-assistant
Copy link

m2-assistant bot commented Sep 11, 2020

Hi @iamprasanthmp! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@thedarkboo
Copy link

thedarkboo commented Oct 15, 2020

@iamprasanthmp Hi, i'm having the same problem.. so far from what i can tell, something in magento is trying to use customer address tables for the category information.

i got the admin working by doing this:

alter table customer_address_entity_decimal add `store_id` smallint(5) NOT NULL DEFAULT 0 COMMENT 'Store Id';
alter table customer_address_entity_datetime add `store_id` smallint(5) NOT NULL DEFAULT 0 COMMENT 'Store Id';
alter table customer_address_entity_text add `store_id` smallint(5) NOT NULL DEFAULT 0 COMMENT 'Store Id';
alter table customer_address_entity_int add `store_id` smallint(5) NOT NULL DEFAULT 0 COMMENT 'Store Id';
alter table customer_address_entity_varchar add `store_id` smallint(5) NOT NULL DEFAULT 0 COMMENT 'Store Id';

by adding the missing store_id field to those tables, indexing will work, and you should be able to gain access to the CATALOG -> CATEGORIES page, but you'll see that none of the categories have any text.. just their id's, and number of products in parentheses.

i started messing around by adding a catagory name and grepping to see where it changed, and if your actually able to save without it erroring.. you'll notice that it's populating the customer_address_entity_varchar table.

i'm pretty sure it's supposed to be using catalog_category_entity_varchar so somewhere it got messed up during migration.

so in my case, i have a lot of sites i've been converting, and the ones that were true 1.9.0.1 convert no problem, but sites that used to be 1.3.2.4 and got migrated over to 1.9.0.1 then migrated again to 2.4.0 are the ones that are failing for me.

@ghost
Copy link
Author

ghost commented Oct 15, 2020

Hello @thedarkboo,
The issue still exist when trying to migrate straight from 1.9.4.5 to 2.4.0.
The work around i figure out was to migrate to 2.3.4 and from there upgrading to 2.4.0.
Hope it solves the issue for you to.

@thedarkboo
Copy link

thedarkboo commented Oct 20, 2020

Hello, i just wanted to follow up.

When i did a select * from catalog_category_entity the attribute_set_id was set to 5 for all my entity_ids other than 1 (which was set to 0) so i did update catalog_category_entity set attribute_set_id = 3 where attribute_set_id = 5; and reindexed and flushed, and everything seems to be working now.

i might be wrong, but i think this might have to do with the way things were inserted in the original db. The order of all the inserts seem to be odd numbers.. so the sequence of ids are inserted by odds like.. 1, 3, 5, 7, 9.

i noticed that in my later 1.9 db's (that work without any problems), they inserts are ordered sequentially 1, 2, 3, 4, 5...

@romastepa
Copy link

romastepa commented Nov 13, 2020

@thedarkboo @iamprasanthmp
you don't need update customer tables!

UPDATE eav_entity_attribute 
SET  entity_type_id = {entity_type_id_you_need}
WHERE entity_attribute_id IN (SELECT entity_attribute_id FROM (
	SELECT eea.*
	FROM `eav_entity_attribute` AS eea
	JOIN `eav_attribute` AS ea ON eea.`attribute_id` = ea.`attribute_id` 
	WHERE ea.`entity_type_id` =  {entity_type_id_you_need}
) as x);

{entity_type_id_you_need} you can check in eav_entity_type (entity_type_code = 'catalog_category')

@thedarkboo
Copy link

thedarkboo commented Nov 13, 2020

@romastepa In the end, none of these solutions worked for me.. because when you set the entity_type_id to something else, it causes problems elsewhere. So in the end, i wrote a script to go through and reindex the db tables to be sequential and it seems to be working fine now.

The issue i had after setting the entity_type_id to 5 was the customer addresses where not showing up in the orders or their overview page.. related to: magento/magento2#5873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants