Sitecore Item Clones is only a thing in the master database

The Sitecore item cloning is a technique in which you can create a copy of an item that inherits the field values of the original items.

In the latest versions of Sitecore (at least from 9.0 and forward) you can ask if an item is a clone:

Database master = Database.GetDatabase("master");
Item item = master.GetItem(someGuid);
bool isClone = item.IsItemClone;

But please notice that the Item.IsItemClone will always return FALSE if you request the item from the WEB database:

Database web = Database.GetDatabase("web");
Item item = web.GetItem(someGuid);
// This value is always false
bool isClone = item.IsItemClone;

This is because the Source and __Source Item fields of an item are the fields on the original item that tells Sitecore that this item is cloned:

Clone from Master database

Clone from Master database

… is not copied to the WEB database when published:

Clone from Web database

Clone from Web database

This is by design. If you would like to know if an item is a clone (to avoid duplicate items in your sitemap, of when creating canonical URL’s, for example), you will need to code a solution yourself.

MORE TO READ:

Advertisements

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 8, Sitecore 9 and tagged , , . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

You are commenting using your Twitter 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.