Discussions

Copy product types

I added a dozen fields with defaults to a product type "MERV 8 Pleats". Now I use the same fields for MERV 13 and MERV 11 pleats, but they have different HTML descriptions, and other defaults that are labor intensive to retype, so it would be nice to keep a product type for each one with the defaults in place.

But it is time consuming to set up each type, can we clone them then change the defaults. Or do the defaults carry over from type to type based on the existing field data?

Many thanks,

Charlie

Posted: Jun 17, 2011

Comments

thioz on October 30, 2013

I ran into the same problem, having one well configured producttype which I had to duplicate which would take me hours and would be madness to do by hand using the UI.

I just figured I could save a LOT of time by looking at the DB structure and how fields are stored and came up with a simple query to copy all fields from my base product type to a new one.

SQL :
INSERT INTO field_config_instance (field_id, field_name, entity_type, data, deleted, bundle) SELECT field_id, field_name, entity_type, data, deleted , '' FROM field_config_instance WHERE entity_type = 'commerce_product' AND bundle = '';

after I generate the new fields I insert the type manually into the commerce_product_type table and for good measure I clear the cache and then attach a product display using the auto-product-display module.

I hope it helps ;)