在Magento中添加产品时,我收到以下错误。
1062 Duplicate entry '24678-1' for key 'UNQ_MAGE_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID
我已按照此处说明的解决方案Integrity constraint violation in Magento custom module
即使在如上所述删除表格中的条目后,我也会收到相同的错误。
我使用的是企业版1.11.0.0
答案 0 :(得分:1)
我已经面临同样的问题并且调试了两天。最后我得到了解决方案并修复了问题。 发生这种情况是由于数据库表不一致。
cataloginventory_stock_item
catalog_product_entity
我已使用以下查询删除了所有不一致数据:
DELETE FROM cataloginventory_stock_item where product_id NOT IN (select entity_id from catalog_product_entity)
您可以在执行删除之前检查记录的数量。
select count(*) from cataloginventory_stock_item where product_id NOT IN (select entity_id from catalog_product_entity)