php - Integrity constraint violation: 1062 Duplicate entry '4974-134' for key 'UNQ_CATALOG_PRODUCT_SUPER_ATTRIBUTE_PRODUCT_ID_ATTRIBUTE_ID' -
i getting above error in magento when adding configurable product (before creating simple products)
this has worked reason failing.
the key value 4974-134 doesn't exist in table:
i've tried re-creating table. i''ve cleare cache/log tables/re-indexed , nothing seems work - each time 4974 (product/entity_id) increments 1 implying being created in catalog_product_entity table isn't:
the way resolve extend/overwrite product model _aftersave function in new module (make sure new class extends extends mage_catalog_model_product
).
like so:
/** * saving product type related data , 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 reason, when creating configurable product trying save object existed in resource adapter possibly - thoughts on appreciated.
Comments
Post a Comment