5

I am trying to publish bucketable items from master to web database.For this purpose i am using the below code:

private void PublishItem(Sitecore.Data.Items.Item scItem, Sitecore.Data.Database _db)
    {
        using (new Sitecore.SecurityModel.SecurityDisabler())
        {
            var publishingTargetItems = Sitecore.Publishing.PublishManager.GetPublishingTargets(_db);
            foreach (var publishingTarget in publishingTargetItems)
            {
                var useDatabaseName = publishingTarget["Target Database"];
                var webDatabase = Sitecore.Data.Database.GetDatabase(useDatabaseName);
                var publisher = new Sitecore.Publishing.Publisher(new Sitecore.Publishing.
                                                      PublishOptions(
                                                      scItem.Database,
                                                      webDatabase,
                                                      Sitecore.Publishing.PublishMode.Smart,
                                                      scItem.Language,
                                                      System.DateTime.Now));
                publisher.Options.RootItem = scItem;
                publisher.Options.Deep = true;
                publisher.Publish();
            }
        }
    }

This works fine for non-bucketable items but fails for bucketable items. I tried with the below solutions available in net but still it is not working https://kb.sitecore.net/articles/256968 https://stackoverflow.com/questions/38362267/sitecore-not-publishing-bucket-folders

we are using Sitecore 8.1 update 3.

Am i missing anything which need to be done to programmatically publish bucketable items ?

  • whats the error msg when it failed? anything in logs? – Dheeraj Palagiri Aug 30 '17 at 8:40
  • No error message or exception. When i see in web db,the item is not there. – Dheeraj p Aug 30 '17 at 9:02
  • is yours multilingual site? sitecore bucket items needs to be published in "en" language in addition to other languages you want to be publihsed, its because all the folders are by default created in "en" rather than in context language. – Dheeraj Palagiri Aug 30 '17 at 9:19
  • What are you passing in as your scItem? Is that the root of your site or your bucket item? And have you published the bucket items' parent item? – jonasag Aug 30 '17 at 9:20
  • 2
    You need to be sure that its ancestors are published too, so somehow, yes you have to publish the whole set of folders – Vicent Galiana Aug 30 '17 at 9:51
3

Instead of publishing the specific item, i published the Item bucket with smart publish option.Now the bucket folders and the item are getting published to target database. Not sure this is the best way to do but it is working for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.