Search code examples
templatessitecoresitecore7

Content migration from one template to another in Sitecore


I want to transfer content of items that belong to one template into another template.

For example, I have 5 fields in first template:

  • Tags
  • Image
  • Download link
  • Title
  • Date

and 5 fields in another template:

  • Type
  • Picture
  • Download Text
  • Title
  • Date

Here first two fields are different in the both the templates and remaining 3 fields are same.

So I want to migrate content of items that belong to first template to the second template. Also, I would like to highlight second template is a newly created template and currently no item from that template is created. So ultimately I am modifying the template of 100 items.

I tried overriding change template method of sitecore TemplateManager.ChangeTemplate(Item item, TemplateChangeList changes) but it empties the fields rather I want to retain the field data.

If anyone has any idea about this, please help.


Solution

  • I don't think there wouldn't be much difficulty to migrate all contents by changing the template. But, the main issue is that there are a number of page items which have to be changed to another template.

    If you do, you can use PowerShellExtension. It takes only 1 second.

    You can get the script idea from Sitecore Workflow Is Not Working