Try our conversational search powered by Generative AI!

Praful Jangid
Feb 6, 2021
  2133
(4 votes)

Bulk publishing of unpublished content items/nodes

In Episerver, we don't have any built in feature that allows us to publish full site (bulk items) in one go. We recently faced one challenge to publish all category nodes.

In CMS, we have an option of Project to perform bulk item update (change of state or publish). But in commerce we don't. And, in our case, we did import of content using custom code and a huge number of items were not published (even we used the SaveAction.Publish).

Then, we decided to write custom code to do that (via scheduled job). And, after doing some RnD, I found that the following Method returns only published items.

ContentRepository.GetChildren<T>(ContentReference contentLink)

Then, the question is how to retrieve the unpublished node/items?

Here is the answer, use the Language option with GetChildren method.

ContentRepository.GetChildren<NodeContent>(parentNode.ContentLink, LanguageSelector.AutoDetect(true))

This is just a trick to get the unpublished items/nodes. And, for bulk publish, you can use the

ContentRepository.Publish(listOfPages);

That's it. You are done.

Thanks

Feb 06, 2021

Comments

Please login to comment.
Latest blogs
Do not upgrade to EPiServer.CMS.Core 12.21.4 without reading this!

Todays update of EPiServer.CMS.Core 12.21.4 alters default sort order in an unexpected way, when you are working with muligple languages and have...

Tomas Hensrud Gulla | May 14, 2024 | Syndicated blog

Upgrade Optimizely CMS From v11 to v12

Why Upgrade? There are many improvements implemented in version 12, but most importantly is that the whole framework is migrated from .Net Framewor...

MilosR | May 13, 2024

Configured Commerce - Infrastructure Updates Ahoy!

I'm very happy to share an important milestone - we no longer have any customers in our legacy v1 environment!  This means that the Configured...

John McCarroll | May 10, 2024

A day in the life of an Optimizely Developer - Enabling Opti ID within your application

Hello and welcome to another instalment of A Day In The Life Of An Optimizely developer, in this blog post I will provide details on Optimizely's...

Graham Carr | May 9, 2024