Removing dead masters from Sitecore

One of the major changes from Sitecore 5.3 to Sitecore 6.x is that Sitecore replaced the masters definintion with branches.

Sitecore masters have been around since Sitecore 4, and they allowed you to have items filled with predefined values. And they determined which types of pages could be created below another type of page. 

Both features have been replaced with the __Standard values template.
Furthermore, Sitecore have also introduced branches, which allows you to create a hierachy of items.

However, this does not mean that Sitecore have removed the field “__masters” which was previously used for storing the masters on an item. This is not a problem unless you import Sitecore items from a Sitecore 5.x solution into a Sitecore 6.x solution.
For example, when upgrading an existing site, you might prefer to create Sitecore packages of content from your old 5.x website to the new 6.x website. These packages cannot contain the masters from the 5.x solution as there is nowhere to dump them in 6.x.

When the masters field on an item is not empty, Sitecore will not read the masters from the __Standard values. This is default behaviour and is expected. So after you have moved your items from 5.x to 6.x, you need to empty the masters field on each of the items you have imported.

The following function blanks the masters field for each item below the specified root item recursively:

public void ProcessItems(Item root)
  foreach (Item item in root.Children)
    if (item.Fields["__masters"] == null)

      item.BranchId = new ID(Guid.Empty);
    ProcessItems(item, ExecuteMode);

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, Sitecore 6 and tagged , . Bookmark the permalink.

1 Response to Removing dead masters from Sitecore

  1. Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.