Wednesday, 20 November 2019

Sitecore PowerShell Script To Upload ANY CSV Data

Are you looking for a quick and handy Sitecore PowerShell script to upload any kind of CSV data? Are you looking to create or update Sitecore items using PowerShell script?

If so, then you landed on right blog post, keep on...

Many times, you require to create/update hundreds of Sitecore items in Sitecore which will take many hours of time if you decide to create/update those items manually.  Moreover, being a techie person it is smart decision to write some script or program to automate such thing and let machine do this bulk and tedious job for you. That's why you are in field of programming, isn't it?

One such incident happen with my team recently where we required to create/update list of 200 countries in Sitecore CMS. We were provided the CSV file with Country name & Country ISO code and we were required to create a Sitecore item for each country resulting 200 items. Hence we decided to spin up some PowerShell script which will read data from CSV file and create Sitecore items accordingly.  A quick search to internet helped us with below Sitecore PowerShell script to do this job in seconds.

#It will create the folder if it is not found
$dataFolder = [Sitecore.Configuration.Settings]::DataFolder
$tempFolder = $dataFolder + "\temp\upload"
$filePath = Receive-File -Path $tempFolder -overwrite

if($filePath -eq "cancel"){

$dropListPath =  "master:/sitecore/content/Master Countries/gigyacountryname"

# Get the item for the Dictionary Folder Container
$dictionaryFolder = Get-Item -Path $dropListPath

# Read CSV file
# 1st row needs to have header of Key, Phrase. Other option is to specify the header on
# the Import-CSV method call using the -Header string[] parameter

$csv = Import-CSV $filePath -delimiter ","

# Wrap the foreach loop in the BulkUPdateContext so we do not fire events and prevent indexing 
#after individual create/update opertaion
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
    foreach($row in $csv) {
        $name = SanitizeName $row.Name
        $itemPath = $dropListPath + "/" + $name
        $item = Get-Item -Path $itemPath -ErrorAction SilentlyContinue
        #check is item already exits
        if($item -eq $null)
            Write-Host ("Creating New Item at: " +  $itemPath)
            Write-Host ("Name:" + $name)
                $item = New-Item -Path $itemPath -ItemType "/sitecore/templates/Project/CountryDropDown"
                Write-Host "Item created: " $item.Name
                Write-Host "Failed to create Item: " $item.Name
                Write-Host $_.Exception.Message
            Write-Host ("Updating Item:" + $item.Name)
        $item["Name"] = $row.Name
        $item["Value"] = $row.Value
        $item.Editing.EndEdit() | Out-Null 
        # we don't want to send the output to the console otherwise it will print False in the console.
        Add-ItemLanguage -Path $item.Paths.Path -Language "en" -TargetLanguage 
        "ar-AE" -IfExist OverwriteLatest  -IgnoredFields ""

# Clean the name in case it has restricted characters
# Todo: use Sitecore.Data.Items.ItemUtil.ProposeValidItemName($args[0])
function SanitizeName{
 $args[0].Replace(".", "").Replace(" ", "").Replace("/", "").Replace("-", "").
Replace("&", "").Replace(":", "").Replace("""", "").Replace("#", "")



  1. Go to Sitecore PowerShell ISE > Copy/Paste above script. 
  2. This will open file dialog > Select CSV file

Below is the CSV format which we were using for above PowerShell Script.

Hope this will help someone!

Monday, 18 November 2019

Sitecore GPI Translation Connector Step By Step

There are many translation service and translation connector for Sitecore avialable in market. Recently, I got a chance to work and intergrate Sitecore GPI Translator.

GPI stands for Globalization Partners International. It provides comprehensive website translation and localization services including:

  • Translation and Copy Writing
  • Multilingual Desktop Publishing
  • Software Localization
  • Website Localization
  • Sitecore Translation Services Connector
  • Global Search Engine Optimization (SEO/SEA/Social Media Localization)

GPI has Translation Connector which enables Sitecore users to manage multi-language websites and initiate translation workflows easily.

Visit to request Sitecore GPI Translator connector demo or aquire the connector.

Now let's look how can you use GPI Conector to translate Sitecore page to different language(s).

Step 1: Select Page > Send for Translation

Step 2: It will open the translation wizard > Click Next

Step 3: Select Source Language and other options > Select Next

Step 4: Select Translation Language in which you want to translate source language page

Step 5: Once Translation is finished by GPI, you will see new language added with translated data

Step 6: If you want to see GPI Translation Service Quote for the page you submitted, you can select View Dashboard under GPI menu

Step 7: You can find all the Translation Service Quote as shown below under GPI Connector

That's it!

Which Sitecore Translation Service / Connector are you using? Share your answer in comment section below.