2013-08-07 15:19 阅读 37


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 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()
        if($this->getTypeId() !== 'configurable')
         * Product Options
        $result = parent::_afterSave();
            $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
        return $result;

    The key bit being:

    if($this->getTypeId() !== 'configurable')


    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.

    点赞 评论 复制链接分享
  • drnvcm3949 drnvcm3949 2013-08-07 16:11

    It's a combination of the product_id and the attribute_id. Whats interesting is 4795 already exists in there.

    I had this issue once after Host Gator transferred a Magento site for me.

    Find out which tables are being used as the FK for these two fiends and make sure that the next increment ID isn't lower than the highest in this table.

    In my case, one of the tables auto_increment ID was reset to 0 so it was trying to create a "1", but that foreign key was already used in the offending table.

    Hope this helps.

    点赞 评论 复制链接分享