CDbCommand failed to execute the SQL statement: SQ

Hello,
 
We have new error on step 5, what we need to do for this ???? we need your support 
http://us504.directrouter.com/~kiviuhys/magento2/index.php/migrate/step5
 
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ’53’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `catalog_product_entity` (`attribute_set_id`, `type_id`, `has_options`, `required_options`, `entity_id`, `sku`, `created_at`, `updated_at`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7)

/home/kiviuhys/public_html/magento2/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/kiviuhys/public_html/magento2/yii/db/ar/CActiveRecord.php(1080): CDbCommand->execute()

1075         {
1076             Yii::trace(get_class($this).'.insert()','system.db.ar.CActiveRecord');
1077             $builder=$this->getCommandBuilder();
1078             $table=$this->getTableSchema();
1079             $command=$builder->createInsertCommand($table,$this->getAttributes($attributes));
1080             if($command->execute())
1081             {
1082                 $primaryKey=$table->primaryKey;
1083                 if($table->sequenceName!==null)
1084                 {
1085                     if(is_string($primaryKey) && $this->$primaryKey===null)

#1


 /home/kiviuhys/public_html/magento2/yii/db/ar/CActiveRecord.php(809): CActiveRecord->insert(null)

804      * @return boolean whether the saving succeeds
805      */
806     public function save($runValidation=true,$attributes=null)
807     {
808         if(!$runValidation || $this->validate($attributes))
809             return $this->getIsNewRecord() ? $this->insert($attributes) : $this->update($attributes);
810         else
811             return false;
812     }
813 
814     /**

#2


 /home/kiviuhys/public_html/magento2/protected/controllers/MigrateController.php(1034): CActiveRecord->save()

1029                                     }
1030                                 }
1031                                 $product2->attribute_set_id = MigrateSteps::getMage2AttributeSetId($product2->attribute_set_id, MigrateSteps::PRODUCT_TYPE_CODE);
1032 
1033                                 //save or update
1034                                 if ($product2->save()){
1035                                     //update to log
1036                                     $migrated_product_ids[] = $product->entity_id;
1037 
1038                                     //catalog_product_entity_int
1039                                     $condition = "entity_id = {$product->entity_id}";

#3


 /home/kiviuhys/public_html/magento2/yii/web/actions/CInlineAction.php(49): MigrateController->actionStep5()

44         $controller=$this->getController();
45         $method=new ReflectionMethod($controller, $methodName);
46         if($method->getNumberOfParameters()>0)
47             return $this->runWithParamsInternal($controller, $method, $params);
48 
49         $controller->$methodName();
50         return true;
51     }
52 }

#4


 /home/kiviuhys/public_html/magento2/yii/web/CController.php(308): CInlineAction->runWithParams(array())

303     {
304         $priorAction=$this->_action;
305         $this->_action=$action;
306         if($this->beforeAction($action))
307         {
308             if($action->runWithParams($this->getActionParams())===false)
309                 $this->invalidActionParams($action);
310             else
311                 $this->afterAction($action);
312         }
313         $this->_action=$priorAction;

#5


 /home/kiviuhys/public_html/magento2/yii/web/CController.php(286): CController->runAction(CInlineAction)

281      * @see runAction
282      */
283     public function runActionWithFilters($action,$filters)
284     {
285         if(empty($filters))
286             $this->runAction($action);
287         else
288         {
289             $priorAction=$this->_action;
290             $this->_action=$action;
291             CFilterChain::create($this,$action,$filters)->run();

#6


 /home/kiviuhys/public_html/magento2/yii/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array())

260         {
261             if(($parent=$this->getModule())===null)
262                 $parent=Yii::app();
263             if($parent->beforeControllerAction($this,$action))
264             {
265                 $this->runActionWithFilters($action,$this->filters());
266                 $parent->afterControllerAction($this,$action);
267             }
268         }
269         else
270             $this->missingAction($actionID);

#7


 /home/kiviuhys/public_html/magento2/yii/web/CWebApplication.php(282): CController->run(“step5”)

277         {
278             list($controller,$actionID)=$ca;
279             $oldController=$this->_controller;
280             $this->_controller=$controller;
281             $controller->init();
282             $controller->run($actionID);
283             $this->_controller=$oldController;
284         }
285         else
286             throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',
287                 array('{route}'=>$route===''?$this->defaultController:$route)));

#8


 /home/kiviuhys/public_html/magento2/yii/web/CWebApplication.php(141): CWebApplication->runController(“migrate/step5”)

136             foreach(array_splice($this->catchAllRequest,1) as $name=>$value)
137                 $_GET[$name]=$value;
138         }
139         else
140             $route=$this->getUrlManager()->parseUrl($this->getRequest());
141         $this->runController($route);
142     }
143 
144     /**
145      * Registers the core application components.
146      * This method overrides the parent implementation by registering additional core components.

#9


 /home/kiviuhys/public_html/magento2/yii/base/CApplication.php(184): CWebApplication->processRequest()

179     public function run()
180     {
181         if($this->hasEventHandler('onBeginRequest'))
182             $this->onBeginRequest(new CEvent($this));
183         register_shutdown_function(array($this,'end'),0,false);
184         $this->processRequest();
185         if($this->hasEventHandler('onEndRequest'))
186             $this->onEndRequest(new CEvent($this));
187     }
188 
189     /**

#10


 /home/kiviuhys/public_html/magento2/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();

5 answers

Profile photo of Mall Staff 184060.00 $tone September 12, 2016
Public

Hi dubidubs ecommerce,

1062 Duplicate entry ’53’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO catalog_product_entity

Seem your Magento 2 site doesn’t a fresh installation? Please note that, this tool only ready with a fresh installation of Magento 2.
Let’s click to ‘Reset’ button and re-start data migration in this step.
Regards,
Mall.

#1
Profile photo of Mall Staff 184060.00 $tone May 24, 2018
Public

Hi there,

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘299802’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote` (`store_id`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, 

That issue because you have selected ‘KEEP ORIGINAL IDs’ in step #7 of our tool. And your M2’s database has more some sample data on sales data section (this comes after add cart actions in front-end)
To solve that, you could run below SQL statement in your M2’s database:

Delete From quote Where entity_id = 299802;

And then, you could continue with delta migration in the step #7
Regards,
Mall.

#3
Profile photo of avishai izhaki 70.00 $tone May 24, 2018
Public

did that, no im getting this message. tried to delete entry 297774 but its still keeping the same error
 
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘297774’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote_item` (`quote_id`, `updated_at`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `free_shipping`, `is_excluded_product`, `item_id`, `created_at`, `product_id`, `store_id`, `is_virtual`, `sku`, `name`, `additional_data`, `is_qty_decimal`, `product_type`, `original_custom_price`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) 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)

#4
Profile photo of Mall Staff 184060.00 $tone May 24, 2018
Public

Hi there,

1062 Duplicate entry ‘297774’ for key ‘PRIMARY’. The SQL statement executed was: INSERT INTO `quote_item` (`quote_id`, `updated_at`, `no_discount`, `weight`, `qty`, `price`, 

Please note, that is another issue. Let’s continue to solve that issue by run below SQL statement in your M2’s database:

Delete From quote_item Where item_id = 297774;

And then, continue with delta migration in step #7 
Regards,
Mall.

#5

Please login or Register to Submit Answer

Written By

Comments