Magento: Set Group_Price and Tier_Price => Duplicate entry
SQLSTATE[23000]: Integrity constraint violation:
I'll try to import products with tier prices and group prices. First time
it works great, but if I try to update it, I'll get an error:
Versuche zu speichern:SQLSTATE[23000]: Integrity constraint violation:
1062 Doppelter Eintrag '4463-0-0-0' für Schlüssel 2
(Duplicate entry for primary key 4463-0-0-0).
I've found a "solution" in a german blog. It recommends to delete all rows
from the tables catalog_product_entity_group_price and
catalog_product_entity_tier_price for the entity_id ( = ProductId).
This works great! But is there a better solution for doing this? A class
method? And why does the magento import process not delete this entrys
before try to inserting the rows?
Another solution was the following code. But it requires a product->save()
action, which was not good for the import performance:
$product->setTierPrice( array() );
$product->save()
$product->setTierPrice($pid["my_tier_price_array"]);
$product->save()
Is there a better solution than a "double save()-method" or directy delete
from the database?
No comments:
Post a Comment