Magento:SQLSTATE [23000]:完整性约束违规:1062重复条目'100000001'用于密钥'UNQ_SALES_FLAT_ORDER_IN

时间:2022-12-13 07:35:17

I have installed Magento 1.9.0.1 and I am live since 1 month. The first order of a Client worked without Problem. But now following error message appears when the order should be processed "There was an error processing your order. Please contact us or try again later."

我安装了Magento 1.9.0.1,我从1个月开始上线。客户的第一个订单没有问题。但是,现在应该处理订单时出现以下错误消息“处理您的订单时出错。请联系我们或稍后再试。”

Log file says: exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000001' for key 'UNQ_SALES_FLAT_ORDER_INCREMENT_ID'' in /home/www/web81/html/lib/Zend/Db/Statement/Pdo.php:228

日志文件说:异常'PDOException',消息'SQLSTATE [23000]:完整性约束违规:1062重复条目'100000001',用于/ home / www / web81 / html / lib / Zend / Db / Statement /中的密钥'UNQ_SALES_FLAT_ORDER_INCREMENT_ID'' Pdo.php:228

I have read a lot of threads and also used Google but could not find a solution. I am a beginner and the shop should work tomorrow again :-( I very much appreciate your help!

我已经阅读了很多主题并且还使用了Google但却找不到解决方案。我是初学者,商店明天应该再次工作:-(非常感谢你的帮助!

Thanks a lot for your help & best regards

非常感谢您的帮助和最好的问候

4 个解决方案

#1


9  

You can try following.

你可以尝试以下。

In app/code/core/Mage/Sales/Model/Resource/Quote.php

Search for isOrderIncrementIdUsed method

搜索isOrderIncrementIdUsed方法

In that method,

在那种方法中,

replace

$bind = array(':increment_id' => (int)$orderIncrementId);

$ bind = array(':increment_id'=>(int)$ orderIncrementId);

with

$bind = array(':increment_id' => $orderIncrementId);

$ bind = array(':increment_id'=> $ orderIncrementId);

------------------------------------------------------------ OR-------------------------------------------------------------------------------

Go to admin->sales-> orders and look up the highest order number (for each store view!)

转到admin-> sales-> orders并查找最高订单号(对于每个商店视图!)

Then look at your database. In the table eav_entity_type you will find all entity types listed. The one of interest to change is where the order number starts, ie. order sales/order. Remember the entity_type_id.

然后看看你的数据库。在表eav_entity_type中,您将找到列出的所有实体类型。有意改变的是订单号开始的地方,即。订单销售/订单。记住entity_type_id。

Next go to the table eav_entity_store. Look up the entity_type_id. Now you can change the value of increment_last_id to your last actual order number. (That is, if you wanted to have your next orderId to be 15000 set increment_last_id to 14999.)

接下来转到表eav_entity_store。查找entity_type_id。现在,您可以将increment_last_id的值更改为上一个实际订单号。 (也就是说,如果你想让你的下一个orderId为15000,则将increment_last_id设置为14999.)

#2


3  

Try this solution. This would definitely help you.

尝试此解决方案。这肯定会对你有所帮助。

The order number 100000001 (i.e. increment ID or increment_id) already exists in your order table, sales_flat_order, and it's failing the order save when someone checks out because increment_ids must be unique.

订单号100000001(即增量ID或increment_id)已存在于您的订单表sales_flat_order中,并且当有人签出时订单失败,因为increment_ids必须是唯一的。

First, verify that you have these order numbers you see in the error messages are indeed already present in the sales_flat_order.increment column. Then, you need to modify the eav_entity_store.increment_id value(s), so that new increment IDs will never overlap with your the already existing order numbers.

首先,确认你有你的错误消息,看到这些订单号确实已经存在于sales_flat_order.increment列。然后,你需要修改eav_entity_store.increment_id值(S),使新的增量ID将永远与你已有的订单号重叠。

Check the maximum value in sales_flat_order.increment_id, and update eav_entity_store.increment_id with a value greater than that.

检查sales_flat_order.increment_id中的最大值,并使用大于该值的值更新eav_entity_store.increment_id。

#3


0  

I quite liked the answer given by Empiro Technologies. I used that answer as inspiration but took a different approach: in my case I had migrated sales_* tables from new database to old copy of database. However I had missed the eav_entity_store table. So I simply updated all of the rows across in that one table, from database to database. That worked fine in my case.

我非常喜欢Empiro Technologies给出的答案。我使用这个答案作为灵感,但采取了不同的方法:在我的情况下,我已将sales_ *表从新数据库迁移到旧数据库副本。但是我错过了eav_entity_store表。所以我只是更新了一个表中的所有行,从数据库到数据库。在我的情况下这很好。

#4


0  

I had been spending quite a bit of time trying to diagnose the same error I had, I couldn't submit orders through paypal with one store view but I could with my other views. After viewing this post I realized that my increment_last_id was the culprit! I just recently imported old customer info/orders from oscommerce->magento using cart2cart and it placed all my orders into my default store view without updating the increment_last_id. After updating that int to the last imported order number I could place orders again!

我花了相当多的时间来尝试诊断我遇到的同样的错误,我无法通过PayPal提交订单,只有一个商店视图,但我可以用我的其他观点。看完这篇文章后,我意识到我的increment_last_id是罪魁祸首!我最近刚使用cart2cart从oscommerce-> magento导入旧的客户信息/订单,它将我的所有订单放入我的默认商店视图而不更新increment_last_id。将int更新为最后导入的订单号后,我可以再次下订单!

#1


9  

You can try following.

你可以尝试以下。

In app/code/core/Mage/Sales/Model/Resource/Quote.php

Search for isOrderIncrementIdUsed method

搜索isOrderIncrementIdUsed方法

In that method,

在那种方法中,

replace

$bind = array(':increment_id' => (int)$orderIncrementId);

$ bind = array(':increment_id'=>(int)$ orderIncrementId);

with

$bind = array(':increment_id' => $orderIncrementId);

$ bind = array(':increment_id'=> $ orderIncrementId);

------------------------------------------------------------ OR-------------------------------------------------------------------------------

Go to admin->sales-> orders and look up the highest order number (for each store view!)

转到admin-> sales-> orders并查找最高订单号(对于每个商店视图!)

Then look at your database. In the table eav_entity_type you will find all entity types listed. The one of interest to change is where the order number starts, ie. order sales/order. Remember the entity_type_id.

然后看看你的数据库。在表eav_entity_type中,您将找到列出的所有实体类型。有意改变的是订单号开始的地方,即。订单销售/订单。记住entity_type_id。

Next go to the table eav_entity_store. Look up the entity_type_id. Now you can change the value of increment_last_id to your last actual order number. (That is, if you wanted to have your next orderId to be 15000 set increment_last_id to 14999.)

接下来转到表eav_entity_store。查找entity_type_id。现在,您可以将increment_last_id的值更改为上一个实际订单号。 (也就是说,如果你想让你的下一个orderId为15000,则将increment_last_id设置为14999.)

#2


3  

Try this solution. This would definitely help you.

尝试此解决方案。这肯定会对你有所帮助。

The order number 100000001 (i.e. increment ID or increment_id) already exists in your order table, sales_flat_order, and it's failing the order save when someone checks out because increment_ids must be unique.

订单号100000001(即增量ID或increment_id)已存在于您的订单表sales_flat_order中,并且当有人签出时订单失败,因为increment_ids必须是唯一的。

First, verify that you have these order numbers you see in the error messages are indeed already present in the sales_flat_order.increment column. Then, you need to modify the eav_entity_store.increment_id value(s), so that new increment IDs will never overlap with your the already existing order numbers.

首先,确认你有你的错误消息,看到这些订单号确实已经存在于sales_flat_order.increment列。然后,你需要修改eav_entity_store.increment_id值(S),使新的增量ID将永远与你已有的订单号重叠。

Check the maximum value in sales_flat_order.increment_id, and update eav_entity_store.increment_id with a value greater than that.

检查sales_flat_order.increment_id中的最大值,并使用大于该值的值更新eav_entity_store.increment_id。

#3


0  

I quite liked the answer given by Empiro Technologies. I used that answer as inspiration but took a different approach: in my case I had migrated sales_* tables from new database to old copy of database. However I had missed the eav_entity_store table. So I simply updated all of the rows across in that one table, from database to database. That worked fine in my case.

我非常喜欢Empiro Technologies给出的答案。我使用这个答案作为灵感,但采取了不同的方法:在我的情况下,我已将sales_ *表从新数据库迁移到旧数据库副本。但是我错过了eav_entity_store表。所以我只是更新了一个表中的所有行,从数据库到数据库。在我的情况下这很好。

#4


0  

I had been spending quite a bit of time trying to diagnose the same error I had, I couldn't submit orders through paypal with one store view but I could with my other views. After viewing this post I realized that my increment_last_id was the culprit! I just recently imported old customer info/orders from oscommerce->magento using cart2cart and it placed all my orders into my default store view without updating the increment_last_id. After updating that int to the last imported order number I could place orders again!

我花了相当多的时间来尝试诊断我遇到的同样的错误,我无法通过PayPal提交订单,只有一个商店视图,但我可以用我的其他观点。看完这篇文章后,我意识到我的increment_last_id是罪魁祸首!我最近刚使用cart2cart从oscommerce-> magento导入旧的客户信息/订单,它将我的所有订单放入我的默认商店视图而不更新increment_last_id。将int更新为最后导入的订单号后,我可以再次下订单!