1

I am trying to clone (duplicate) configurable product with all associated simple products and option prices.

Does anyone have any idea how to do it or where to start?

2
  • So the simple products should be duplicated as well, i.e. if you have 1 conf. product and 3 simple products you want to end up with 2 conf. and 6 simple products? Or should just the associations be copied? Commented Nov 19, 2014 at 9:34
  • I want to clone configurable, clone simples, make associations to new simples, copy option prices
    – mkutyba
    Commented Nov 19, 2014 at 18:27

1 Answer 1

2

You can write an observer for catalog_model_product_duplicate, check if the duplicated product is a configurable product, then duplicate all associated products as well. How to start with the observer:

public function duplicateConfigurableProduct(Varien_Event_Observer $observer)
{
    $originalProduct = $observer->getCurrentProduct();
    if ($originalProduct->getTypeId() === Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {

        // duplicate associated products:
        foreach ($originalProduct->getTypeInstance()->getUsedProducts() as $simpleProduct) {
            $simpleProduct->duplicate();
        }

    }
}

Copying the associations and option prices would be too much for the scope of this answer but this should already point you in the right direction. You have access to the duplicated configurable product with $observer->getNewProduct()

You should know that a duplicated product normally has to be edited manually immediately after duplication because its SKU is empty otherwise. If you duplicate the associated products automatically you still need to edit those as well.

1
  • I think observer is a good starting point. I started with rewriting Mage_Adminhtml_Catalog_ProductController but it not very elegant solution. Regarding the SKUs, I plan to save them with the suffix "clone" or something like that.
    – mkutyba
    Commented Nov 27, 2014 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.