Let's assume that I have version 1, 2 and 3 of the same Sitecore item.
For test purpose only I need to publish version 2.
Is this possible?
Let's assume that I have version 1, 2 and 3 of the same Sitecore item.
For test purpose only I need to publish version 2.
Is this possible?
You don't need to manipulate with workflow state of newer versions or with publishing restrictions.
You can use Sitecore API and PublishOptions.PublishDate
property. Just pass the datetime when your chosen version was created as the constructor argument like:
new PublishOptions(..., ..., version.Statistics.Created);
And pass it to PublishItemContext
:
var options = new PublishOptions(version.Database, targetDatabase, PublishMode.Full, version.Language, version.Statistics.Created);
var context = PublishManager.CreatePublishItemContext(version.ID, options);
context.PublishContext = new PublishContext(options);
return PublishItemPipeline.Run(context);
I wrote a blog post which explains in details how and why it works. You can read it here:
It is possible by playing with one of those two things: