How can we identify all the Sitecore which are cloned item and how can we unclone them programmatically? Can we do this using Powershellscript?
2 Answers
You can get the cloned items for an item using the following code:
item.GetClones(true);
You can un-clone item using the following:
if (item.IsClone)
{
var clone = new CloneItem(item);
clone.Unclone();
}
You can get cloned items for an item using Sitecore PS as:
Get-ItemClone -Path master:\content\home
Following is the documentation of how you can get cloned-items for an item using powershell: https://doc.sitecorepowershell.com/appendix/common/get-itemclone
Basically if an sitecore Item have "__Source" field value populated, then it means it's an clone of another item.
So you can query (from code OR using powershell script) to find any items with that field is populated to find out all the clones.
Refer:
https://doc.sitecore.com/users/93/sitecore-experience-platform/en/clones.html
Does Sitecore cloning create extra records in Link Database?