Publish Bulk Items in Sitecore using Sitecore Powershell Extensions

Every Sitecore site will have a different set of requirement and one of the requirement could be Publish Bulk Items in Sitecore. If you have the same requirement then you are at right place. :)

Publish Bulk Items In Sitecore

 

This post is in accordance with my previous two posts:

  1. Export Sitecore Items
  2. Update Sitecore Items

This might be the case for your requirement, first Export Sitecore Items, then it could be Update Sitecore Items in bulk and then I’m sure there would be the third one to Publish Sitecore Items in Bulk.

I’ve written Sitecore Powershell script which would do the job easier. In Update Sitecore Items — I provided the sample file, the same file you can use for Bulk Publish.

Sample CSV File: pt_Publish_Sitecore_Items (I generally prefix the file with language so that we know which language version items are getting published)

Below script will first ask the user for the CSV File. Then it will ask for Target Database to publish Sitecore Items — The reason for providing this option is because every Sitecore site have the staging environment and it’s always better to verify the changes. So you can accordingly select the target database and after verifying you can push it Live. Once processing is done file will be deleted. Publish Mode is set to Smart.

Note, Sample CSV File has two important columns which are required by this script, ItemPath and Language — Items will be published in the provided language.

(more…)

Share

Read More

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:

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.

(more…)

Share

Read More

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.

(more…)

Share

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 😉

(more…)

Share

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

(more…)

Share

Read More

Sitecore Items – Get Keyword Reference Items

Challenge:

We need to know in how many Sitecore items word “keyword” is present. This requirement arrived because client had a contract with one third party service and now they have planned to discard the contract with that party and change the service with other party. Now these third party services provide some script which we add in Sitecore item and now for all the items where we have script used by first service need to be replaced with another. And the site is very big and we can’t check each and every item where the “keyword” is present.

So after discussing with Urvesh, we came up with an idea to fetch from Database directly.

001

Solution:

Ultimately sitecore stores the value in Database into three tables — Versioned, Unversioned and Shared fields. So we wrote a query which will hit all the three tables and provide us the item ids where the keyword is present. The site is in many languages and if in any language version the keyword is present then it will be captured. This saved enormous time and money. :) We’ve heavily used this utility for providing the report to the Content Authors and Migration. Additionally we have created many such tools which can update the items in bulk, we will share it soon.

(more…)

Share

Read More

Sitecore Module – Delete Multiple Items

Delete Multiple Items – A module for Content Authors to Delete Multiple Items.

Sitecore 7.0 Sheer UI – ASPX Application
Sitecore 8.2 Speak UI

A Module for deleting Multiple Sitecore Items. This application was built first as an ASPX page (You can access it with /sitecore/admin/DeleteMultipleItems/DeleteMultipleItems.aspx), then provided an option in Sitecore Start Menu which can be used as an application as shown in screenshot. After that I learnt and explored Speak application via Knockout JS and then built a new application based on SPEAK UI which can run on Sitecore 8.2. Download the package based on the Sitecore version in which you are going to install.

Download it from Sitecore Marketplace

Documentation: GitHub

Source Code: GitHub

Well, If you are working on your DEV Machine, then you can easily delete multiple items with the help of Sitecore Rocks. Refer: http://www.sitecore-cms.de/2013/12/how-to-delete-more-than-one-item-in.html

Output:

Delete Multiple Items
Delete Multiple Items – Sheer UI
Delete Multiple Items
Delete Multiple Items – Speak UI

 

Thanks to my friend – Vikram for blogging the very good series of articles for SPEAK application. Thsi helped in gaining basic knowledge about Sitecore Speak application.

Share

Read More

Sitecore Module – Sitecore Child Item Count

Sitecore Child Item Count Module is for getting the child item of the selected item in Content Editor. It also provide an option to specify the template id of child item, if you want to fetch the items of any specific template. It works based on the index. It also check the current Language. If your current selected language is Japanese and if the child item doesn’t exist with Japanese language version than it won’t include in child count.

For more information: Documentation

Download it from – Sitecore Marketplace

Source Code: GitHub

Share

Read More

How to use Linq Lambda Expression IEqualityComparer For IEnumerable.Except

One of the thing that sometimes annoys is Lambda Expression with IEqualityComparer. I was trying to pick items with Except Comparer from the list. After doing quick search on google found the below extension method which can be used in such scenario. 

public static IEnumerable Except(this IEnumerable first, IEnumerable second, Func<TSource, TSource, bool> comparer)
{
return first.Where(x => second.Count(y => comparer(x, y)) == 0);
}

How to use:

List myItemsList = source.Except(myDeals, (x, y) => x.ID == y.ID).Take(requiredCount).ToList();

This will return the list of items except item(s) which match with an ID in myDeals. 

Share

Read More

Sitecore query with hypen or dashes

Challenge:

Sometimes your sitecore query might contains hypen or space and you get an error: “unterminated literal string in Query”. It is because the query contains an illegal character and the solution is to escape the “-“.So we need to add hash(#) around the word in the query.

Query: /sitecore/content/My Site/Event/ABC-Items

Earlier I referred the below article and implimented in one of the project:

Escaping dashes/“-” in Sitecore Queries. Datasource query Update

This is actually the nice example. But while working on another project, I applied below piece of code which I think is better and easy solution then the one given in above link.

Solution:


StringBuilder startItemPath = new StringBuilder(@"/");
startItemPath.Append(string.Join("/", myItemsFolder.Paths.FullPath.Split(new char[] { '/' },
StringSplitOptions.RemoveEmptyEntries).Select(x => string.Format("#{0}#", x))));

allItems = contextDb.SelectItems(“fast:” + startItemPath + “//*[@@templateid = ‘” + templateID + “‘]”).ToList();

By applying above solution. The query will contain “#” around all the words in query. It won’t create any harm for the query to execute.

If you know any other better approach then do comment below.

Happy Querying!

Share

Read More