2010-12-07 80 views
4
編輯產品時

它的影音1.4.1.1的Magento,從AV 1.3.2.4
升級當我嘗試編輯一個產品出現錯誤消息:MySQL錯誤在Magento

exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6028-0-2' for key 'PRIMARY'' 

如果我嘗試重新索引價格我在exception.log中有相同的消息
我認爲問題出現在catalog_product_website表中,因爲如果我刪除該行,我可以運行價格索引,但是當我嘗試編輯產品以將其分配給一個網站時,我收到了同樣的信息。
一個奇怪的事情是,catalog_product_website表只有2列,約3主鍵表異常會談(右?)
這裏是整個堆棧跟蹤:

2010-12-07T12:12:41+00:00 ERR (3): 
exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6028-0-2' for key 'PRIMARY'' in /var/www/ortoweb1314/lib/Zend/Db/Statement/Pdo.php:234 
Stack trace: 
#0 /var/www/ortoweb1314/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) 
#1 /var/www/ortoweb1314/lib/Zend/Db/Adapter/Abstract.php(468): Zend_Db_Statement->execute(Array) 
#2 /var/www/ortoweb1314/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array) 
#3 /var/www/ortoweb1314/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array) 
#4 /var/www/ortoweb1314/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php(260): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...') 
#5 /var/www/ortoweb1314/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price/Default.php(133): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Default->_prepareFinalPriceData('6028') 
#6 /var/www/ortoweb1314/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Indexer/Price.php(192): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price_Default->reindexEntity('6028') 
#7 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Indexer/Abstract.php(144): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Indexer_Price->catalogProductSave(Object(Mage_Index_Model_Event)) 
#8 /var/www/ortoweb1314/app/code/core/Mage/Catalog/Model/Product/Indexer/Price.php(255): Mage_Index_Model_Indexer_Abstract->callEventHandler(Object(Mage_Index_Model_Event)) 
#9 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Indexer/Abstract.php(85): Mage_Catalog_Model_Product_Indexer_Price->_processEvent(Object(Mage_Index_Model_Event)) 
#10 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Process.php(185): Mage_Index_Model_Indexer_Abstract->processEvent(Object(Mage_Index_Model_Event)) 
#11 [internal function]: Mage_Index_Model_Process->processEvent(Object(Mage_Index_Model_Event)) 
#12 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Indexer.php(252): call_user_func_array(Array, Array) 
#13 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Indexer.php(154): Mage_Index_Model_Indexer->_runAll('processEvent', Array) 
#14 /var/www/ortoweb1314/app/code/core/Mage/Index/Model/Indexer.php(219): Mage_Index_Model_Indexer->indexEvent(Object(Mage_Index_Model_Event)) 
#15 /var/www/ortoweb1314/app/code/core/Mage/Catalog/Model/Product.php(525): Mage_Index_Model_Indexer->processEntityAction(Object(Mage_Catalog_Model_Product), 'catalog_product', 'save') 
#16 [internal function]: Mage_Catalog_Model_Product->afterCommitCallback() 
#17 /var/www/ortoweb1314/app/code/core/Mage/Core/Model/Resource/Abstract.php(104): call_user_func(Array) 
#18 /var/www/ortoweb1314/app/code/core/Mage/Core/Model/Abstract.php(310): Mage_Core_Model_Resource_Abstract->commit() 
#19 /var/www/ortoweb1314/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(663): Mage_Core_Model_Abstract->save() 
#20 /var/www/ortoweb1314/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->saveAction() 
#21 /var/www/ortoweb1314/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('save') 
#22 /var/www/ortoweb1314/app/code/core/Mage/Core/Controller/Varien/Front.php(177): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#23 /var/www/ortoweb1314/app/code/core/Mage/Core/Model/App.php(304): Mage_Core_Controller_Varien_Front->dispatch() 
#24 /var/www/ortoweb1314/app/Mage.php(596): Mage_Core_Model_App->run(Array) 
#25 /var/www/ortoweb1314/index.php(80): Mage::run('', 'store') 
#26 {main} 

我希望有人能幫助我,我真的出去想法,現在:(

編輯:我已經增強了異常日誌的消息,這樣我就可以看到整個查詢,這就是:

#2 /var/www/ortoweb1314/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(
    "INSERT INTO `catalog_product_index_price_final_tmp` SELECT `e`.`entity_id`, `cg`.`customer_group_id`, `cw`.`website_id`, ta_tax_class_id.value AS `tax_class_id`, ta_price.value AS `orig_price`, IF(IF(ta_special_from_date.value IS NULL, 1, IF(DATE(ta_special_from_date.value) <= cwd.date, 1, 0)) > 0 AND IF(ta_special_to_date.value IS NULL, 1, IF(DATE(ta_special_to_date.value) >= cwd.date, 1, 0)) > 0 AND ta_special_price.value < ta_price.value, ta_special_price.value, ta_price.value) AS `price`, IF(IF(ta_special_from_date.value IS NULL, 1, IF(DATE(ta_special_from_date.value) <= cwd.date, 1, 0)) > 0 AND IF(ta_special_to_date.value IS NULL, 1, IF(DATE(ta_special_to_date.value) >= cwd.date, 1, 0)) > 0 AND ta_special_price.value < ta_price.value, ta_special_price.value, ta_price.value) AS `min_price`, IF(IF(ta_special_from_date.value IS NULL, 1, IF(DATE(ta_special_from_date.value) <= cwd.date, 1, 0)) > 0 AND IF(ta_special_to_date.value IS NULL, 1, IF(DATE(ta_special_to_date.value) >= cwd.date, 1, 0)) > 0 AND ta_special_price.value < ta_price.value, ta_special_price.value, ta_price.value) AS `max_price`, tp.min_price AS `tier_price`, tp.min_price AS `base_tier` FROM `catalog_product_entity` AS `e` 
INNER JOIN `customer_group` AS `cg` 
INNER JOIN `core_website` AS `cw` 
INNER JOIN `catalog_product_index_website` AS `cwd` ON cw.website_id = cwd.website_id 
INNER JOIN `core_store_group` AS `csg` ON csg.website_id = cw.website_id AND cw.default_group_id = csg.group_id 
INNER JOIN `core_store` AS `cs` ON csg.default_store_id = cs.store_id AND cs.store_id != 0 
INNER JOIN `catalog_product_website` AS `pw` ON pw.product_id = e.entity_id AND pw.website_id = cw.website_id 
LEFT JOIN `catalog_product_index_tier_price` AS `tp` ON tp.entity_id = e.entity_id AND tp.website_id = cw.website_id AND tp.customer_group_id = cg.customer_group_id 
INNER JOIN `catalog_product_entity_int` AS `tad_status` ON tad_status.entity_id = e.entity_id AND tad_status.attribute_id = 80 AND tad_status.store_id = 0 
LEFT JOIN `catalog_product_entity_int` AS `tas_status` ON tas_status.entity_id = e.entity_id AND tas_status.attribute_id = 80 AND tas_status.store_id = cs.store_id 
LEFT JOIN `catalog_product_entity_int` AS `ta_tax_class_id` ON ta_tax_class_id.entity_id = e.entity_id AND ta_tax_class_id.attribute_id = 81 AND ta_tax_class_id.store_id = 0 
LEFT JOIN `catalog_product_entity_decimal` AS `ta_price` ON ta_price.entity_id = e.entity_id AND ta_price.attribute_id = 60 AND ta_price.store_id = 0 
LEFT JOIN `catalog_product_entity_decimal` AS `ta_special_price` ON ta_special_price.entity_id = e.entity_id AND ta_special_price.attribute_id = 61 AND ta_special_price.store_id = 0 
LEFT JOIN `catalog_product_entity_datetime` AS `ta_special_from_date` ON ta_special_from_date.entity_id = e.entity_id AND ta_special_from_date.attribute_id = 62 AND ta_special_from_date.store_id = 0 
LEFT JOIN `catalog_product_entity_datetime` AS `ta_special_to_date` ON ta_special_to_date.entity_id = e.entity_id AND ta_special_to_date.attribute_id = 63 AND ta_special_to_date.store_id = 0 
INNER JOIN `cataloginventory_stock_status` AS `ciss` ON ciss.product_id = e.entity_id AND ciss.website_id = cw.website_id WHERE (e.type_id='simple') AND (IF(tas_status.value_id > 0, tas_status.value, tad_status.value)=1) AND (e.entity_id IN('6028')) AND (ciss.stock_status=1)", 
    array(
    ), 
) 

整個excpetion.log文件在這裏:http://www.dowhiletrue.net/exception.txt.tar.gz

+1

parloir你是怎麼進行升級?你是否從命令行執行它?幾周前我剛剛升級到1.3到1.4,這是一場噩夢。我學到的技巧是你必須備份你的數據庫,創建一個全新的數據庫,加載你備份的數據,然後重新安裝(我嘗試了很多其他的方法,並且總是遇到外鍵衝突,直到我做了它如上所述)。 – Chris 2010-12-07 17:22:51

+0

好吧,實際上我刪除了所有的v1.3文件並將它們替換爲v1.4,然後我運行安裝,連接到我用於1.3 – OSdave 2010-12-07 19:23:13

+1

的db。這可能是您的問題。我試圖不刪除數據庫,我總是有重大錯誤。當您刪除數據庫以避免重要衝突時會發生某些情況。如果你還沒有嘗試過,我會嘗試這裏列出的方法http://www.webshopapps.com/blog/2010/02/upgrading-magento-to-version-1-4-keeping-it-simple /接受我的建議,不要跳過任何步驟:) – Chris 2010-12-08 02:08:57

回答

1

看來問題不在catalog_product_website表中。價格指數表中的問題,可能是以前版本中的一些舊記錄,應該刪除。我會建議你重新索引所有索引。完整的reindex進程首先清除索引表,然後用數據完成表。它應該有所幫助。

如果完全重建索​​引不起作用,那麼您的分期付款有可能會觀察到prepare_catalog_product_price_index_table事件,這些事件修改了重新索引select的方式,使用具有相同主鍵的行數相乘的額外連接方式進行選擇。它也可能導致這樣的錯誤。

乾杯, 伊萬

0

愚蠢,因爲這聽起來,因爲你得到複製 - auto_incremented - 鍵,你嘗試過增加你的AUTO_INCREMENT值該表?假設這是一個以某種方式衝突的數據庫狀態,這將解決這個問題。如果你將PK跳100,而你仍然得到PK違規,那麼代碼可能試圖插入兩次相同的記錄。

這將是相關查詢:

ALTER TABLE catalog_product_website AUTO_INCREMENT=1234