Remove Sitecore Item Language Versions

In Multilingual Site, Content Authors many times create duplicate items or copy items and in that case, all the versions of the items are getting copied. And they want to remove the language versions in bulk so that no wrong language version with wrong data gets published live.

If you are implementing and looking for the quick solution, see below code:

Language languageRemove = Sitecore.Globalization.Language.Parse(languageCode);
Item rootItem = db.GetItem(rootItemPath, languageRemove);
if (rootItem != null)
{
    using (new Sitecore.SecurityModel.SecurityDisabler())
    {
        if (rootItem.Versions.Count == 0)
        {
            sb.Append("Language version not found. Item: " + rootItemPath).Append(" Language: ").Append(languageCode).Append("<br/>");
        }
    else
    {
        //Remove all the versions from item
        rootItem.Versions.RemoveAll(false);
    }
}

If content authors are working on many items and if they remove language versions manually then for each it will take hours of them to get it done. This tool will help content authors to remove the unnecessary language versions from the Sitecore Items in few seconds/minutes.

Sitecore Marketplace Module – Remove Item Language Versions

Source Code – GitHub

Sitecore Module includes below core db items and a file:

/sitecore/content/Applications/Remove Item Language Versions
/sitecore/content/Documents and settings/All users/Start menu/Programs/Remove Item Language Versions
/sitecore/admin/removeitemlanguageversions.aspx

Remove Item Language Versions

In this utility, you need to provide the Sitecore Item IDs or Paths separated on a line and select the languages which you want to remove from the items and click Remove.

Note: This will remove all the versions of the selected language.

I’ve provided the access only to Administrators, so this tool can only be accessed by Administrators.

If you don’t like to install module (which I believe you won’t do on CM server) — You can use the .aspx file, which you can download from: ASPX File And copy it to /sitecore/admin/RemoveItemLanguageVersions.aspx — I have done this and using this couple of times in a month as needed.

Screenshots:

Remove Item Language Versions

Remove Item Language Versions

Happy Sitecoring! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

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