Search code examples
magentoduplicatesproduct

Magento Duplicate Product without Custom Options


I´m using the following Code to duplicate Products "on the fly", the most of them are Simple Products with Custom options.

Is it possible to duplicate them without Custom Options?

I want to Display them right after i duplicated them - but without custom Options.

Some Ideas?

    $clone=$product->duplicate();
    $clone->setSku($clonedSku);
    $clone->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);   
    $clone->setStatus(1); // AKTIV=1
    $clone->setVisibility(4);
    $clone->setTaxClassId(2);
    $clone->setCategoryIds("93");
    $cloneID=$clone->getId();

Solution

  • There is no way to duplicate a product without the custom options (without overriding the product model), but you can duplicate the product and remove the custom options after that.

    $clone = $product->duplicate();
    //all your additional code here
    //then delete the options
    $options = $clone->getOptionInstance()->getProductOptionCollection($clone);//get all the options
    foreach ($options as $option){//loop through the options
        $option->delete();//delete each option
    }