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.

Read More

Update Sitecore Items using Sitecore PowerShell with CSV Data

Hello Sitecorians,

 

Are you looking for a quick and easy way to update Sitecore Items — Sitecore PowerShell does that job very easily.

 

In my previous blog — I provided the PowerShell script/module by which you can export data using Sitecore PowerShell Extensions. If you see that script/file properly – The first two header rows are “ItemPath” and “Language“. These columns are required for the below script to update the data. I’ve kept the language column as required for this because I work on Sitecore Site having more than 10 languages and in that case, we need a language option so that the correct language version gets updated. And other header rows in the file are the field names. Once I have exported the data in CSV – do the required updates in Excel and import the same file using the below script. It will import updated data back to Sitecore Items.

 

I referred to a couple of blogs for importing CSV files and in all, we have to provide the Path for the file but for providing the path, that file should reside on the server. So I looked for some other way around it and found an easy way to upload the file, process it, and then delete it. Let me know if you have any other ideas/suggestions for it.

Read More

Export Sitecore Item Data using Sitecore PowerShell

I heard a lot about Sitecore PowerShell – it’s the great tool and one of the best module on Sitecore Marketplace. Also the most downloaded module crossing SIM. One fine day I was installing SXA, that also said — Before you install the SXA package, please make sure that you have installed: Sitecore PowerShell extensions (full 4.5 for Sitecore 8) from https://marketplace.sitecore.net/Modules/S/Sitecore_PowerShell_console.aspx. Then I started exploring PowerShell from the Video Series by Michael West on YouTube. These are awesome videos to learn and understand Sitecore PowerShell. And once you have viewed the videos, after that when you look at the script, you will easily understand it. For every Sitecore Developer, it’s worth exploring Sitecore PowerShell. You’ll really like and enjoy with it. You won’t open Visual Studio to code, you will only open Sitecore for scripting – as it says – Sitecore PowerShell ISE (Integrated Scripting Environment).

 

Export Sitecore Items Data — We are using this tool a lot to give the reports or data to the client, created in a .aspx file – It was written by my friend. And then I modified it based on requirements. After exploring PowerShell. I thought to implement it in PowerShell. And it got ready in couple of hours as I knew how to work with Sitecore PowerShell 😉

Read More

An error occurred in Sitecore Experience Editor

While working on Sitecore Site — I faced an error for few pages in the experience editor. As always quickly I tried to search on google to find the solution, but I didn’t found any solution related to an error. And the reason is — The error that I was getting was totally different on the browser while the actual problem was something else.

Error:  An error occurred. [Log message: Value cannot be null. Parameter name: version]

sitecore_experience_editor

Read More