简体   繁体   中英

Sitecore incremental publish of an item

Is it possible to do incremental publish of an item? I am trying to do that in the following way:

var masterDatabase = Factory.GetDatabase("master");
var webDatabase = Factory.GetDatabase("web");
var contentItem = masterDatabase.GetItem("/sitecore/content/path to item");

PublishOptions options = new PublishOptions(
    masterDatabase, 
    webDatabase,
    PublishMode.Incremental, 
    Language.Current, 
    DateTime.Now)
{
    RootItem = contentItem,
    Deep = true
};

Publisher publisher = new Publisher(options);
publisher.PublishAsync();

but I get the following error on the last line:

An exception of type 'System.InvalidOperationException' occurred in Sitecore.Kernel.dll but was not handled in user code. Additional information: A root item can not be specified for incremental publishing

The contentItem variable is a bucket, which contains other bucketable items. Is there any way to do incremental publishing for it?

No. It's not possible. Incremental is only possible for the whole database.

For item only those 2 options are possible:

  1. Smart publish - publish differences between source and target database.
  2. Republish - publish everything.

Just to add on Marek answer

Incremental Publishing does not take any root item. It makes use of the Publish Queue table to know which items to publish. Sitecore will query the Properties Table from the Master Database to retrieve the last publish date and the target database.

Base on the timestamp retrieved, all the items from the PublishQueue table, which have their date greater or equal to the last published timestamp, are published.

This is a reason why when you select publish item , there is only these 2 options:

  1. Smart Publish
  2. Full Publish

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM