On purchase we are unpublishing products if there are no items left in stock using this code:
var productClone = product.CreateWritableClone<Product>();
productClone.ChangedBy = "ProductEOL";
productClone.StopPublish = DateTime.Now;
_contentRepository.Service.Save(productClone, SaveAction.Publish, AccessLevel.NoAccess);
The product is unpublished but the ChangedBy is set to the username of the person that purchased the last item, why is that?
We have some other functions like importing that sets ChangedBy and that works just fine. In the sync function there are no logged in user so I guess i might have something to do with that?
Very strange. I just checked the code and ChangedBy is only set to the current user if it is null. I don't have a good answer for you however, so you should contact developer support service - there might be something else in your code that changed that
Thanks, I will try this in Foundation and contact the devloper support if it is the same there.
I got curious and did a test:
If I try to set ChangedBy to "MJ" on a product I get the following results:As anonymous: ChangedBy = "installer"As logged in user: ChangedBy = logged in username
If I do the same on a CMS page I get
As anonymous: ChangedBy = "MJ"As logged in user: ChangedBy = logged in username
I alse see alot of changed by "installer" in our Commerce instance, don't know where that is coming from.
So this really is something to report. I will send this to Optimizely and have them sort things out.
Thanks Mari for your test.
I believe installer is a system convention for "empty" ChangedBy property.
It is reported as COM-14467 if you want to follow up.
Now it is a public bug and can be followed here: