Update Sitecore Items using Sitecore PowerShell with CSV Data

Hello Sitecorians,

 

Are you looking for 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 – 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 language option so that 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 below script. It will import updated data back to Sitecore Items.

 

I referred a couple of blogs for importing CSV File 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 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.

Sample CSV File: Click Here

 

First, we need to upload the file on the server – Here I’m uploading the file on the server in the Data Folder and then using Import-Csv command, file data will be imported.

Once the file is available on the server and we have got the path and data in $resultSet variable, It then iterates through the data and updates the Item field value. Make sure headers are present as it’s referred as field names and based on that each field value will be updated. At the end, it will remove the file from the server.

Below is the full script, you can copy and execute it in Sitecore PowerShell! 😉

Screenshots:

01-UploadFile

02-Bulk Update Complete Message

Good Reads:

https://www.kasaku.co.uk/2016/04/10/importing-csv-data-in-sitecore/

Happy Sitecore PowerShelling! :)

Share

Leave a Reply

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