SQL state Duplicate entry when delta step 5

Hi,
When trying to delta migrate step 5 (products) I got this error:
Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘10859’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `catalog_product_bundle_option_value` (`value_id`, `option_id`, `store_id`, `parent_product_id`, `title`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)
 
Any idea how to fix this? 
 
Thanks! 
 
 
 

11 answers

Profile photo of Mall Staff 153110.00 $tone September 17, 2020
Public

Hi there,

1062 Duplicate entry ‘10859’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `catalog_product_bundle_option_value` (`value_id`, `option_id`, `store_id`, `parent_product_id`, `title`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)

You can try with steps as following to solve that issue:
1. Run the followings SQLs in your M2 database:

Delete From catalog_product_entity Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From catalog_product_entity_varchar Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From catalog_product_entity_text Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From catalog_product_entity_int Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From catalog_product_entity_decimal Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From catalog_product_entity_datetime Where entity_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'catalog_product_entity');
Delete From tax_class Where class_type='PRODUCT' AND class_id NOT IN (Select m2_id From ub_migrate_map_step_5 where entity_name = 'tax_class');
Delete From downloadable_link Where link_id NOT IN (Select m2_id From ub_migrate_map_step_5_product_download where entity_name = 'downloadable_link');
Delete From catalog_product_option Where option_id NOT IN (Select m2_id From ub_migrate_map_step_5_product_option where entity_name = 'catalog_product_option');
Delete From catalog_product_bundle_option Where option_id NOT IN (Select m2_id From ub_migrate_map_step_5_product_option where entity_name = 'catalog_product_bundle_selection');
Delete From catalog_product_option_type_price Where option_type_price_id NOT IN (Select m2_id From ub_migrate_map_step_5_product_option where entity_name = 'catalog_product_option_type_price');

2. And then, you continue with data migration in step #5
And tell me to know how it goes. 
Regards,
Mall.
 
 

#1
Profile photo of Mikko Kankaanpää 200.00 $tone September 17, 2020
Public

Hi, Thanks. That solved that error, but I face new one:
[Processing][delta] Step #5 migration completed with 15 Product Super Attributes;
……………….Error: Call to undefined method stdClass::save() in /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/controllers/Step5Controller.php:1741
Stack trace:
#0 /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/controllers/Step5Controller.php(279): Step5Controller->_migrateCatalogProductBundleOptions(Array, Array, Array, ‘1’)
#1 /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/commands/RunCommand.php(74): Step5Controller->actionRun()
#2 /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/commands/RunCommand.php(33): RunCommand->_migrateData(Object(Step5Controller))
#3 [internal function]: RunCommand->actionIndex(Object(Step5Controller), false, ‘update’, NULL)
#4 /home/customer/www/xxx.com/public_html/pub/ub-tool/yii-1.1.19/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(RunCommand), Array)
#5 /home/customer/www/xxx.com/public_html/pub/ub-tool/yii-1.1.19/console/CConsoleCommandRunner.php(71): CConsoleCommand->run(Array)
#6 /home/customer/www/xxx.com/public_html/pub/ub-tool/yii-1.1.19/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#7 /home/customer/www/xxx.com/public_html/pub/ub-tool/yii-1.1.19/base/CApplication.php(185): CConsoleApplication->processRequest()
#8 /home/customer/www/xxx.com/public_html/pub/ub-tool/yii-1.1.19/yiic.php(33): CApplication->run()
#9 /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/ubdatamigration_cli.php(5): require_once(‘/home/customer/…’)
#10 /home/customer/www/xxx.com/public_html/bin/ubdatamigration(4): require_once(‘/home/customer/…’)
Best regards,
Mikko

#2
Profile photo of Mall Staff 153110.00 $tone September 17, 2020
Public

Hi there,

Error: Call to undefined method stdClass::save() in /home/customer/www/xxx.com/public_html/pub/ub-tool/protected/controllers/Step5Controller.php:1741

Please tell me to know what is the version of our module in your instance?
Regards,
Mall.

#3
Profile photo of Mall Staff 153110.00 $tone September 17, 2020
Public

Hi there,
So, you can try with steps as following:
1. Run the following SQLs in your M2 database:

DELETE FROM ub_migrate_map_step_5 WHERE entity_name = 'catalog_product_entity' AND m2_id NOT IN (Select entity_id From catalog_product_entity);
DELETE FROM ub_migrate_map_step_5_product_option WHERE entity_name = 'catalog_product_option' AND m2_id NOT IN (Select option_id From catalog_product_option);
DELETE FROM ub_migrate_map_step_5_product_option WHERE entity_name = 'catalog_product_option_type_value' AND m2_id NOT IN (Select option_type_id From catalog_product_option_type_value);
DELETE FROM ub_migrate_map_step_5_product_option WHERE entity_name = 'catalog_product_option_type_price' AND m2_id NOT IN (Select option_type_price_id From catalog_product_option_type_price);
DELETE FROM ub_migrate_map_step_5_product_option WHERE entity_name = 'catalog_product_bundle_option' AND m2_id NOT IN (Select option_id From catalog_product_bundle_option);
DELETE FROM ub_migrate_map_step_5_product_option WHERE entity_name = 'catalog_product_bundle_selection' AND m2_id NOT IN (Select selection_id From catalog_product_bundle_selection);

2. Clean the cache of our module by run command: rm -rf pub/ub-tool/protected/runtime/cache/
3. You continue with data migration in step #5.
Regards,
Mall.

#5
Profile photo of Mikko Kankaanpää 200.00 $tone September 17, 2020
Public

Hi,
Thanks! It worked little bit but I again faced new problem:
[Processing][delta] Step #5 migration completed with 100 Product Bundle Options;
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………
Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘10914’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `catalog_product_bundle_option_value` (`value_id`, `option_id`, `store_id`, `parent_product_id`, `title`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)
baseos | u2-zvwg5cqf3ds7@c76485.sgvps.net:~/www/uraltone2.com/public_html$ 
 
Br,
Mikko

#6
Profile photo of Mall Staff 153110.00 $tone September 18, 2020
Public

Hi Mikko,

1062 Duplicate entry ‘10914’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `catalog_product_bundle_option_value` (`value_id`, `option_id`, `store_id`, `parent_product_id`, `title`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)

You can try with these steps:
1. Run the following SQL query in your M2 database:

Delete From catalog_product_bundle_option_value Where value_id = 10914;

2. And then, you continue with the data migration in step #5.

Regards,
Mall.
 

#7
Profile photo of Mikko Kankaanpää 200.00 $tone September 18, 2020
Public

Hi, thanks! There was some more dublicates but I managed to fix them with this query. 
 
BUT at step 6 I got another error:
Processing][delta] Step #6 migration completed with 100 Customers
……………………………………………………………………………………………………………………………………..
Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘263539’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `customer_address_entity` (`is_active`, `entity_id`, `parent_id`, `created_at`, `updated_at`, `country_id`, `firstname`, `lastname`, `street`, `telephone`, `city`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10)
 
Any fix for this one?
Many thanks!!
 
Best regards,
Mikko

#8
Profile photo of Mall Staff 153110.00 $tone September 18, 2020
Public

Hi there,

1062 Duplicate entry ‘263539’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `customer_address_entity` (`is_active`, `entity_id`, `parent_id`,

You can try these steps:
1. Run the following SQL query in your M2 database:

Delete From customer_address_entity Where entity_id = 263539;

2. And then, you continue with the data migration in step #6.

Regards,
Mall.

#9
Profile photo of Mikko Kankaanpää 200.00 $tone September 21, 2020
Public

Hi, 
Unfortunately I still have problems. I managed to get step 5 and step 6 done, but after I checked our magento 2 (flushed caches, reindexed etc) and there was not all new products or customers imported.
So I restored backups and started again. I delta migrated step 5 and got the same error than last time (first message in this thread) and run the query that you suggested (second message in this thread).
After that I flushed cached, reindexed but there are only about 14 products imported from M1. 200 newest product is still missing. Last time delta migration of step 5 imported more products but not all.
If I now run 
php -f bin/ubdatamigration run --step=5 --mode=update
I got: 
[Processing][delta] in step #5: ……………………………………………………………………………
[Processing][delta] Step #5 migration completed with 1 Products;
Step #5 migration completed successfully
Total Data Migrated: 100%
So I´m stuck…
Any idea how to proceed? 
Many thanks again! 
Best regards,
Mikko

#10
Profile photo of Mall Staff 153110.00 $tone September 22, 2020
Public

Hi Mikko,

So I´m stuck…
Any idea how to proceed? 

Please try with these steps:

1. Run the following SQL query in your M2 database:

UPDATE `ub_migrate_map_step_5` SET `created_time` = '2000-01-01 00:00:00' Where entity_name = 'catalog_product_entity';

2. And then you run the delta migration in step #5 with the ‘update’ mode by running the CLI command:

php -f bin/ubdatamigration run --step=5 --mode=update;

And then reindex the data and check the issue you mentioned. And tell me how it goes.

Regards,
Mall.

#11

Please login or Register to Submit Answer

Written By

Comments