magento / data-migration-tool

Magento Data Migration Tool
https://devdocs.magento.com/guides/v2.3/migration/bk-migration-guide.html
Open Software License 3.0
338 stars 199 forks source link

Undefined offset: 9 in /vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php on line 433 #112

Closed quienti closed 8 years ago

quienti commented 8 years ago

Magento 1 => 1.9.2.2 Magento 2 => 2.1.0 Data Migration Tool => 2.1.0

sans titre 1

After try reset : sans titre 2

victor-v-rad commented 8 years ago

Hi @quienti It is hard to figure out what wrong with your eav_attribute_group and eav_entity_attribute. You could share your DB dump of the next Magento 1 tables: eav_attribute_group eav_attribute_set eav_attribute eav_entity_attribute catalog_eav_attribute customer_eav_attribute eav_entity_type You can send it through the email (find it in my profile https://github.com/victor-v-rad) We will try to migrate it.

quienti commented 8 years ago

Mail sent and thank you for your response

victor-v-rad commented 8 years ago

internal issue MAGETWO-55303 was created

trungnguyenbss commented 8 years ago

i'm facing the same problem. Can you post what caused this issue and how to fix? Thanks alot!

victor-v-rad commented 8 years ago

We are working on this issue. Most probably you have different eav_entity_type.entity_type_id in your Magento 1 and Magento 2

andreymoskvenkov commented 8 years ago

Ha Ha! I am getting the same error, when migrating from CE 1.9.2.1 to EE 2.1. But I am getting an error as "undefined offset 13". 13 - it is a "Default" attribute set ID of "order_item" entity type. It falls, when is trying to move "price" attribute to "product-details" group. However "order_item" entity type attributes are not assigned to any attribute group. I think the fix is: do not move such attributes into "product-details" group. Just to change the condition to: if ($attributes[$attributeId]['attribute_code'] == $attributeCode && isset($attributeSetGroups[$record->getValue('attribute_set_id')][$attributeGroupCode]) ) { $record->setValue( 'attribute_group_id', $attributeSetGroups[$record->getValue('attribute_set_id')][$attributeGroupCode] ); }

andreymoskvenkov commented 8 years ago

Sh****. Now I get SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9' for key 'PRIMARY'

theycallmepepper commented 8 years ago

I just ran into this one as well. (1.8.0.1 -> 2.1.0) @andreymoskvenkov The first answer gives a little more context on the second error you received: http://magento.stackexchange.com/questions/92578/data-migration-eav-step-error

I don't have a solid solution at the moment.

andreymoskvenkov commented 8 years ago

I think the issue appears, when we have a project, which was initially implemented on some older Magento version and then upgraded many times to the latest version. I have another project on my local, which is on CE 1.9.2.1 as well, but I don't see attributes for "order", "order_item", "invoice", etc entity types in the "eav_attribute" table. Therefore for now I think the solution for me would be: just to delete all attributes from "eav_attribute" table, where entity_type_id > 4. However need to keep in mind that there may be attributes for some custom entity types, which probably should not be deleted. However in my case there I have only Magento entity types.

andreymoskvenkov commented 8 years ago

Yeah, now I am getting an error related to older backend types: [ERROR]: Class catalog/product_attribute_backend_finishdate does not exist but mentioned in: eav_attribute.backend_model for attribute_id=63

victor-v-rad commented 8 years ago

@quienti in your DB the field eav_attribute_group.attribute_group_name has French names. Rename it back to English and try migration again

quienti commented 8 years ago

I can not try a new migration this week, but as soon as I have a few minutes, I try! Thanks

andreymoskvenkov commented 8 years ago

Btw, SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '9' for key 'PRIMARY' error is thrown, when a rollback is being run. So, rollback does not work in case, when some error occurs.

andreymoskvenkov commented 8 years ago

Sorry, no, rollback does not work anyway, but this issue Duplicate entry '9' for key 'PRIMARY' is thrown, when Migration tool tries to insert not existing in CE edition entity type "rma_item". This entity type's ID is hardcoded in the Migration tool's helper as "9". Therefore if your eav_entity_type table contains more than 8 "standard" entity types (standard entity types are: catalog_category
catalog_product
creditmemo
customer
customer_address
invoice
order
shipment ) then the tool throws an exception, that "Duplicate entry '9'". In our table we have a lot of old entity types, such as "order_item", "invoice_item", etc + we have a custom entity type: "m_filter" from ManaDev extension. Therefore the migration tool would always throw an exception in my case. I have resolved it by deleting all entity types, except entity types from the list above.

victor-v-rad commented 8 years ago

This entity type's ID is hardcoded in the Migration tool's helper as "9"

internal ticket MAGETWO-55399 was created

Nehace40 commented 8 years ago

@victor-v-rad i have changed my file like internal issue MAGETWO-55303 but again getting same error

victor-v-rad commented 8 years ago

@MagentoTest1111 2.1.1 release is not ready yet. It might be better to wait for a while

baltechies commented 8 years ago

Hi, I have same issue. Notice: Undefined offset: 1 in {PROJECT_PATH}/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php on line 433

Magento 1 => 1.9.2.2 Magento 2 => 2.1.0 Data Migration Tool => 2.1.0

rtowings commented 8 years ago

Hi @baltechies, Undefined offset 1 in Data.php line 433 is usually a secondary error. Please empty your Magento2 database, Migrate settings. Then Migrate data using the -vvv flag and post:

  1. your error
  2. the first two lines of the stack trace.
baltechies commented 8 years ago

Hi @rtowings , I have tried it many time and now did it again but same error. 1) Error [Exception]
Notice: Undefined offset: 1 in /Users/balvinderSingh/Sites/comitstore-mg2/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Dat
a.php on line 433

2) First two lines Exception trace: () at /Users/balvinderSingh/Sites/comitstore-mg2/vendor/magento/framework/App/ErrorHandler.php:61 Magento\Framework\App\ErrorHandler->handler() at /Users/balvinderSingh/Sites/comitstore-mg2/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php:433 Migration\Step\Eav\Data->moveAttributeToGroup() at /Users/balvinderSingh/Sites/comitstore-mg2/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php:400

I have attached the screenshot of terminal. screen shot 2016-08-22 at 9 08 41 pm

rtowings commented 8 years ago

Hi @baltechies,

Just to be clear. Did you begin your latest attempt with an empty Magento2 database?

baltechies commented 8 years ago

Yes. I did it with empty Magento2 Database. I have the backup of magento2 database after fresh installation.

rtowings commented 8 years ago

OK, try running the following query on your Magento1 database.

select distinct attribute_set_id from eav_attribute_group where attribute_set_id > 8 and attribute_set_id not in (select attribute_set_id from eav_attribute_set where entity_type_id = 4);

baltechies commented 8 years ago

I run this query on magent1 database and its return 31 rows.

baltechies commented 8 years ago

@rtowings Is there any clue? What should I do further?

rtowings commented 8 years ago

What's going on is that your Magento1 database has some missing data (or extra data, depending on your perspective). Basically, in M1 attributes are grouped into sets in the tables eav_attribute_group and eav_attribute_set. The query you ran on your M1 database returned the attribute_set_id numbers that exist in eav_attribute_group and should (but don't) exist in eav_attribute_set. This is likely due to a bug in an earlier Magento release that deleted the attribute_groups, but did not delete the corresponding sets.

You have 3 choices: 1) add the missing records to eav_attribute_set in your M1 database. 2) delete the extra records from eav_attribute_group in your M1 database - I dislike this option, because there is risk in destroying data, but it should work. (make sure you backup first!) 3) wait for an update in the migration tool that might look for this issue and take appropriate action.

I'll message you separately with some instructions.

baltechies commented 8 years ago

@rtowings Thank you. I will look into database and update you. I have checked database roughly and found that eav_attribute_set table has entry which is not exist in eav_attribute_group table.

baltechies commented 8 years ago

@rtowings All attribute_set_id numbers that exist in eav_attribute_group are also exist in eav_attribute_set. I am not capturing what is going wrong here.

rtowings commented 8 years ago

[Edited] Hi @baltechies.

I am concerned that there are issues with your empty M2 database. Before going any farther, I would recommend that you re-run your install (dump this new, empty M2 db for later reference), then attempt the migration into the newly created, empty M2 database. Please remember to use the -vvv flag. (You will still receive an error during the EAV step, but I think it will be slightly different);

The query I had you run earlier on your M1 database [[select distinct attribute_set_id from eav_attribute_group where attribute_set_id > 8 and attribute_set_id not in (select attribute_set_id from eav_attribute_set where entity_type_id = 4);]] returns a list of attribute_set_id that DO exist in eav_attribute_group, but DO NOT exist in eav_attribute_set.

To rule out sets from other entities, here is a slightly modified query to run against your M1 database that should (but may not) yield the same result: select distinct attribute_set_id from eav_attribute_group where attribute_set_id > 8 and attribute_set_id not in (select attribute_set_id from eav_attribute_set); If this query yields 0 rows, then we need to look elsewhere for your problem.

If it yields any rows, then it has found a set(s) in eav_attribute_group that doesn't exist in eav_attribute_set;

baltechies commented 8 years ago

Hi @rtowings I have installed fresh copy of magento 2.1 and run migration on this. But same issue nothing change.

I have run "select distinct attribute_set_id from eav_attribute_group where attribute_set_id > 8 and attribute_set_id not in (select attribute_set_id from eav_attribute_set);" and its return 0 rows.

victor-v-rad commented 8 years ago

Please check that in your DB the field eav_attribute_group.attribute_group_name in English.

baltechies commented 8 years ago

@victor-v-rad There are 127 rows. What should I check?

baltechies commented 8 years ago

@victor-v-rad Its seems that there is an issue in data migration tool version 2.1. I installed a fresh copy of magento 2.0.7 and data migration tool version 2.0.7. Then I am able to migrate magento1 database into magento2. Now I am facing is a new issue, I am unable to edit and add new product, Its showing empty screen. Can you please suggest related to this? screen shot 2016-08-30 at 3 31 03 pm

victor-v-rad commented 8 years ago

@quienti The issue was fixed in the latest release of the tool 2.1.1 Please recheck

quienti commented 8 years ago

@victor-v-rad Thank you, I will check in a few days

baltechies commented 8 years ago

@victor-v-red I am able to migrate data from magento 1 to magento 2.1 with data migration tool 2.1.1. But I faced some issues, Like 1) products and categories are not shown on frontend. 2) In admin panel, category page (Product-> categories) throwing exception error. Error is a:4:{i:0;s:139:"Notice: Undefined offset: 564 in [Magento_PATH]/vendor/magento/module-eav/Model/ResourceModel/ReadHandler.php on line 166";i:1;s:6828:"#0

victor-v-rad commented 8 years ago

@baltechies Not able to identify the cause. You could send your DB dump (remove all passwords in it before). See my email in my profile https://github.com/victor-v-rad I would try to migrate and test

victor-v-rad commented 8 years ago

Thank you @baltechies for the DB you sent Migrated successfully and the issues you described are exist. In order to solve it I need new issue in github please make it and Copy/Past your last comment

baltechies commented 8 years ago

@victor-v-rad I have created a new issue #153

victor-v-rad commented 8 years ago

It seems the initial issue is fixed and I close it. Feel free to reopen if it is still actual

quienti commented 8 years ago

Just for information, my migration work correctly

Thanks

ilol commented 8 years ago

Great!

techverx commented 8 years ago

Hi guyz, I migrated data from magento 1.9.2.4 to magento 2.1.1 and successfully completed all steps. Everything looks good and all data imported but when i go to Products->categories i am seeing this error.

Notice: Undefined offset: 31 in /var/www/coral/vendor/magento/module-eav/Model/ResourceModel/ReadHandler.php on line 166

Help much appreciated. :)

victor-v-rad commented 8 years ago

It is hard to figure out what is wrong in your case You could share DB dump (remove all passwords before) of Magento 1 and send it through email (find it in my profile https://github.com/victor-v-rad) We will try to migrate it to reproduce and fix

myselfgaurav commented 8 years ago

I am stuck since 3 days trying to migrate my magento 1 to magento 2. I keep on getting below error:

[PDOException] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '136' for key 'PRIMARY'

i did reset and did reset multiple times still no success , how can i find which database has duplicate value , please help me to fix i have attached my magento 1 database also .(to you in seperate mail)

lano-vargas commented 7 years ago

I am also having issue with migrating from 1.9.2.1 to 2.1.0.

In the first run I get [Exception]
Notice: Undefined offset: 1 in ../../../magento2/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php on line 209 Second run I get [PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-Migration_Default' for key 'EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME'

I am not sure how to fix pass this issue, has anyone got a solution please share. thank's.

PradeepAvion commented 7 years ago

[Exception]
Notice: Undefined offset: 19 in /home/bestalzheimers/public_html/newbestalzheimers/vendor/magento/data-migration-tool/src/Migration/Step/Ea
v/Data.php on line 249

Magento 1 => 1.9.1.0 Magento 2 => 2.1.2 Data Migration Tool => 2.1.2

screenshot from 2017-05-17 12 52 44

natsoman commented 7 years ago

i am trying to migrate 1.7.0.2 to 2.1.7 [Exception] Notice: Undefined offset: 19 in /home/m2/public_html/vendor/magento/data-migration-tool/src/Migration/Step/Eav/Data.php on line 278

I don't know how to fix it

screen shot 2017-06-22 at 00 34 08
manojroka commented 7 years ago

@natsoGR did you find any fix for it? I am getting the exactly same error.

natsoman commented 7 years ago

@manojroka unfortunately no.