dtxq82489 2013-08-07 15:19
浏览 43
已采纳

完整性约束违规:1062重复条目“UNQ_CATALOG_PRODUCT_SUPER_ATTRIBUTE_PRODUCT_ID_ATTRIBUTE_ID”的重复条目“4974-134”

I am getting the above error in Magento when adding a configurable product (before creating simple products)

This has worked but for some reason it is now failing.

The key value 4974-134 doesn't even exist in the table: enter image description here

I've tried re-creating the table. I''ve cleare cache/log tables/re-indexed and nothing seems to work - each time the 4974 (product/entity_id) increments by 1 implying it is being created in the catalog_product_entity table but it isn't:

enter image description here

  • 写回答

2条回答 默认 最新

  • donglu6303 2013-08-08 09:10
    关注

    The only way that I could resolve this eventually was to extend/overwrite the Product model _afterSave function in a new module (make sure the new class extends extends Mage_Catalog_Model_Product).

    Like so:

    /**
     * Saving product type related data and init index
     *
     * @return Mage_Catalog_Model_Product
     */
    protected function _afterSave()
    {
        $this->getLinkInstance()->saveProductRelations($this);
    
        if($this->getTypeId() !== 'configurable')
        {
            $this->getTypeInstance(true)->save($this);
        }
    
    
        /**
         * Product Options
         */
        $this->getOptionInstance()->setProduct($this)
            ->saveOptions();
    
        $result = parent::_afterSave();
    
        Mage::getSingleton('index/indexer')->processEntityAction(
            $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
        );
        return $result;
    }
    

    The key bit being:

    if($this->getTypeId() !== 'configurable')
        {
            $this->getTypeInstance(true)->save($this);
        }
    

    }

    It looks like for some reason, when creating the configurable product it was trying to save an object that already existed in the resource adapter possibly - Some thoughts on this would be appreciated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的