Clone a variation in code (Commerce 7.10.0)


Has anyone got an example of how to copy/clone a variation in code (via IContent or Entry)? Basically I'm creating products in code and for each I need to create a copy of an existing variation, change the code and a few other fields, and save and link to the new product.

Sounds like it should be fairly simple (load up the original, change some fields (code, etc.), and save as new) in theory but unless I’m missing something it’s not working out that way!


May 27, 2015 9:13


Without testing, I believe you can call IContentRepository.Copy with the content reference of catalog content you want to clone, and point to same parent link. Some unique fields will be autogenerated.



Jun 03, 2015 11:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.