After a little deeper dive into the code, it seems that following happens:
ContentReference contentReference = this._contentProviderDatabase.Save(content, action, this._principalAccessor.CurrentName());
where CatalogContentProvider executes:
ContentReference contentReference = this._catalogContentCommitterHandler.Save(content as CatalogContentBase, action, PrincipalInfo.CurrentPrincipal.Identity.Name);
Try adding this to your code. I believe this is what you want.
writableProduct.ChangedBy = "AutomaticTask";
There is also an content.CreatedBy property, for jobs that create the initial/first version of the content.
It seems to be this bug COM-16450 - i.e. it's known but was not fixed on 14.x
It works, but partially :)
If the product is updated with the ChangedBy modification, then it stays with the same value even if editor changed that product.
Probably due to the bug that Quan mentioned.
FWIW I ping-ed the commerce development team again. they fixed the issues on 13.x and planned to port the fix to 14.x. not sure why that hasn't happened
For some automatic tasks, we would like to know, that the content has been recently modified by the task rather than by an editor user.
To achive this in CMS content one can use IPrincipalAccessor and this works for PageData.
However it does not work for Catalog content (EntryContentBase), and after saving the content, it still uses name of last user.
Consider following code:
Before running the code, after content has been created by editor:
And after running the code: