3

We have added an event to publish:complete and it is working fine when we publish in Sitecore (manually). However, when we do the exact same publish in code the event is not fired.

The code:

var publishOptions = new PublishOptions(item.Database, publishDb, PublishMode.Smart, lang, DateTime.Now);

var publisher = new Publisher(publishOptions);
publisher.Options.RootItem = item;
publisher.Options.Deep = true;
publisher.Publish();

The publish works but the event is not fired. Caches are cleared and it seems that the publish:end is fired, but not the complete (and we need that one).

Why is the complete not fired?

Sitecore version: 8.2-upd2

1 Answer 1

3

I don't know if this is a bug or not.. couldn't find a reference to it. But the issue got fixed by using a different approach (code) to do the publish:

PublishManager.PublishItem(item, new[] { publishDb }, new [] { lang }, true, true);

I checked the Sitecore code behind these and found that the Publisher does indeed trigger the publish:end but not the publish:complete.

If you search the numerous blog posts written about publishing programmatically you'll get both ways of publishing presented. But apparently they don't act the same. If you need the publish:remote events, remember to use the PublishManager.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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