2012-02-21 33 views
3

在将magento从1.4.0.1升级为1.5.1.0后,我无法提交发票。 当我指着我的浏览器Sales -> Orders -> [order] View -> Invoice并单击Submit invoice,我得到的错误说Unable to save the invoice.无法保存发票

我检查了这是怎么回事,我exception.log文件,这里是错误:

exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000001' for key 'UNQ_INCREMENT_ID'' in /home/misbhv/domains/*/public_html/lib/Zend/Db/Statement/Pdo.php:234 
Stack trace: 
#0 /home/misbhv/domains/*/public_html/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) 
#1 /home/misbhv/domains/*/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) 
#2 /home/misbhv/domains/*/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `sk...', Array) 
#3 /home/misbhv/domains/*/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(337): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `sk...', Array) 
#4 /home/misbhv/domains/*/public_html/lib/Zend/Db/Adapter/Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `sk...', Array) 
#5 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(414): Zend_Db_Adapter_Abstract->insert('sklep_sales_fla...', Array) 
#6 /home/misbhv/domains/*/public_html/app/code/core/Mage/Sales/Model/Mysql4/Order/Abstract.php(417): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Sales_Model_Order_Invoice)) 
#7 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Sales_Model_Mysql4_Order_Abstract->save(Object(Mage_Sales_Model_Order_Invoice)) 
#8 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(150): Mage_Core_Model_Abstract->save() 
#9 /home/misbhv/domains/*/public_html/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php(272): Mage_Core_Model_Resource_Transaction->save() 
#10 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Adminhtml_Sales_Order_InvoiceController->saveAction() 
#11 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('save') 
#12 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#13 /home/misbhv/domains/*/public_html/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch() 
#14 /home/misbhv/domains/*/public_html/app/Mage.php(627): Mage_Core_Model_App->run(Array) 
#15 /home/misbhv/domains/*/public_html/index.php(80): Mage::run('', 'store') 
#16 {main} 

我不知道该怎么做,也不能谷歌任何解决方案。任何帮助将非常感激!

+0

这篇文章可能有帮助:http://www.magentocommerce.com/boards/v/viewthread/234665/#t335407 – seanbreeden 2012-02-21 21:37:16

回答

6

从溶液:http://www.magentocommerce.com/boards/v/viewthread/234665/#t335407有道理:

i had the same error code. the increment number and the last order number are not synchrone anymore. what we did is the following:

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

after some help from a fooman post, we did this: \"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.\” (in my install it is 4)

\"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.)\”

Hope that this helps.

+0

就是这样!我不知道为什么我无法找到它。非常感谢! :) – mbajur 2012-02-21 22:27:12

+0

完美的+1对我来说 – 2013-12-10 11:14:42

0

我认为你有一个新的限制,以独特的一排,在1.4.x版鸵鸟政策都需要。你应该看到重复的行,并解决与所有的级联约束与另一个不同的increment_id创建一个新的行。 你可以看到重复的行下一个SQL语句:

SELECT row FROM table GROUP BY row HAVING COUNT(*)>1; 

后,你需要看到重复的行,在我的情况,我可以删除重复JEY,因为这些都是一个错误。是probaby,你可以删除行重复,因为这是你的Magento中的错误受伤。 在我的情况下,magento scrip更新停止在尝试更新表的结构。

0

我在Fooman插件和所有increment_id之前的空白处有问题。该查询固定它我..

UPDATE `sales_flat_invoice` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_order` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_invoice_grid` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_order_grid` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_shipment` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_creditmemo` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_shipment_grid` SET increment_id = trim(increment_id); 
UPDATE `sales_flat_creditmemo_grid` SET increment_id = trim(increment_id); 
UPDATE `eav_entity_store` SET increment_last_id = trim(increment_last_id); 
1

其实我看了看上面的解决方案,并认为这可能工作,你是在正确的轨道上,但我尝试不同的东西:

更改“increment_last_id”字段没有立即解决问题 - 实际上有一组订单存在于先前的商店视图中,该视图被删除,共享相同的订单ID,所以当Magento试图在重复错误中写入失败的ID时。

我通过查看我的exception.log发现了问题(它实际上告诉我导致问题的订单ID)。

删除这些订单并通过编辑increment_last_id字段重新对齐新订单解决了我的问题。现在我的新订单从上次的数字开始,并且没有订单ID的冲突了。