Search code examples
phpmagentocloneproduct

Clone product model/object in Magento


Is it possible to clone a product model/object instance in Magento? Basically I'm hooking in to the save event of a product and wish to automatically create a child product based of the main product. The information will be largely the same, except for SKU's and an attribute. I've tried this:

$product = clone $parent_product;
$product->setName('I am testing');
$product->save();

But it doesn't work. Any ideas?


Solution

  • I think you need to look at Mage_Catalog_Model_Product->duplicate()