Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Draft added when trying to create and publish content programmatically

$
0
0

Hi 

When trying to create a commerce content programmatically using code similar to this

var clone = content.CreateWritableClone<CustomProduct>();
//Update clone properties here 
var batch = new List<CustomProduct> { clone };
foreach (var branch in customModel.LanguageVersions)
{
    var branchContent =  contentRepository.Get<CustomProduct>(contentLink, branch.CultureInfo).CreateWritableClone<CustomProduct>();
    //update branchContent 
    batch.Add(updatedContent);
}
_contentRepository.Publish(batch);

I get *two* versions of my content instances for each language except the main one. 

One of them is in published state and created by "you", the other one is in a draft and created by "system".

When I open my product language instance I get to the draft by default where none of the properties were updated. If I then revert changes to published state - everything is correct.

Did anybody face the issue?

PS Tried to post a screenshot here. "Only users belong to partner companies are able to upload image files." - a bit annoying, isn't it?


Viewing all articles
Browse latest Browse all 6894

Trending Articles