Magento error while trying to duplicate a product with tier price
I am trying to duplicate a product using the code (Magento Community Edition)
$product = Mage::getModel('catalog/product')->load($id);
$newProduct = $product->duplicate();
$newProduct->setStatus(1);
$newProduct->setSku(rand(1, 99999));
$newProduct->getResource()->save($newProduct);
It works fine for products without tier pricing. But shows the error for
products with tier pricing...
a:5:{i:0;s:98:"SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '64-1-0-10.0000-0' for key 2";i:1;s:2045:"#0
/Library/WebServer/Documents/magentoversion/app/Mage.php(462):
Mage_Core_Model_Config->getModelInstance('eav/entity_attr...',
'SQLSTATE[23000]...')
regards,
Leo
No comments:
Post a Comment