Error on Step 7

Answered
Public

Hi,
 
I am getting an error on Step 7. 
 
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ’37’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `mgny_sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, `entity_id`, `state`, `status`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `base_discount_amount`, `base_discount_canceled`, `base_grand_total`, `base_shipping_amount`, `base_shipping_canceled`, `base_shipping_tax_amount`, `base_subtotal`, `base_subtotal_canceled`, `base_tax_amount`, `base_tax_canceled`, `base_to_global_rate`, `base_to_order_rate`, `base_total_canceled`, `discount_amount`, `discount_canceled`, `grand_total`, `shipping_amount`, `shipping_canceled`, `shipping_tax_amount`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_canceled`, `tax_amount`, `tax_canceled`, `total_canceled`, `total_qty_ordered`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `email_sent`, `quote_id`, `shipping_address_id`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `increment_id`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `global_currency_code`, `order_currency_code`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `created_at`, `updated_at`, `shipping_incl_tax`, `base_shipping_incl_tax`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15, :yp16, :yp17, :yp18, :yp19, :yp20, :yp21, :yp22, :yp23, :yp24, :yp25, :yp26, :yp27, :yp28, :yp29, :yp30, :yp31, :yp32, :yp33, :yp34, :yp35, :yp36, :yp37, :yp38, :yp39, :yp40, :yp41, :yp42, :yp43, :yp44, :yp45, :yp46, :yp47, :yp48, :yp49, :yp50, :yp51, :yp52, :yp53, :yp54, :yp55, :yp56, :yp57, :yp58, :yp59, :yp60, :yp61, :yp62, :yp63, :yp64)

/home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/db/CDbCommand.php(358)

346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }
362 
363     /**
364      * Executes the SQL statement and returns query result.
365      * This method is for executing an SQL query that returns result set.
366      * @param array $params input parameters (name=>value) for the SQL execution. This is an alternative
367      * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing
368      * them in this way can improve the performance. Note that if you pass parameters in this way,
369      * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa.
370      * Please also note that all values are treated as strings in this case, if you need them to be handled as

Stack Trace

#0

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/db/ar/CActiveRecord.php(1080): CDbCommand->execute()
 

#1

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/db/ar/CActiveRecord.php(809): CActiveRecord->insert(null)
 

#2


  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/protected/controllers/MigrateController.php(2412): CActiveRecord->save()

2407                                 }
2408                                 //we have changed store_id in magento2
2409                                 if ($sales_order2->store_id){
2410                                     $sales_order2->store_id = MigrateSteps::getMage2StoreId($sales_order2->store_id);
2411                                 }
2412                                 if ($sales_order2->save()){
2413                                     $migrated_order_ids[] = $sales_order->entity_id;
2414 
2415                                     //sales_order_address
2416                                     $models = Mage1SalesOrderAddress::model()->findAll("parent_id = {$sales_order->entity_id}");
2417                                     if ($models){

#3

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/actions/CInlineAction.php(49): MigrateController->actionStep7()
 

#4

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/CController.php(308): CInlineAction->runWithParams(array())
 

#5

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/CController.php(286): CController->runAction(CInlineAction)
 

#6

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array())
 

#7

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/CWebApplication.php(282): CController->run(“step7”)
 

#8

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/web/CWebApplication.php(141): CWebApplication->runController(“migrate/step7”)
 

#9

+
  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/yii/base/CApplication.php(184): CWebApplication->processRequest()
 

#10


  /home/madetoorderjeans/migrate-12-04-2020/migrate-data-tool/index.php(13): CApplication->run()

08 
09 //remove the following line when in production mode
10 defined('YII_DEBUG') or define('YII_DEBUG', true);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();

1 answer

Profile photo of ubdev Staff 98030.00 $tone April 13, 2020
Public

Hi Hardik Patel, 
It seems you’re using our old script on Github.

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ’37’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `mgny_sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, `entity_id`, `state`

The error indicates that your M2 database had sample/testing data in the sales data section which led to the issue.  
 
Since the script on Github was outdated and no longer maintained for long. It might lead to unexpected issues beyond the scope of our support.
 
So, we highly recommend you consider moving forward with our UB Data Migration Pro module for more enhancements and bug fixes. The Pro module will save you pretty much time. 
 
Thanks for your understanding.
 
Regards,
Ubertheme team

#1

Please login or Register to Submit Answer

Written By

Comments