We're using a webapi to add available deliverymethods and price to a variant from an external system.
The variant is retrieved, created as a writeable cone, updated with new data, then saved. But the save sometimes crashes, with the following message:
System.ComponentModel.DataAnnotations.ValidationException: [Missing text '/Commerce/validation/commercemedianotfound' for 'English']
When i debug the code, the CommerceMediaCollection contains more images than what is visible on the product in the admin-interface. As if the entry has "invisible" images linked.
The problem seems to originate from InRiver (OnPremise version). The error only occurs when the customer creates a new product in inriver, a new variant in inriver and connects a new image in inriver. Not when connecting an already existing image, for example.
I have verified that the image is imported to episerver, i can see it in the media catalog. The variant also gets the correct image as an asset.
this is the line that crashes, giving the above error message.
ContentRepository.Save(variant, SaveAction.Publish.SetExtendedActionFlag(ExtendedSaveAction.ClearVersions), AccessLevel.NoAccess);
I tried adding a new image to the variant in the edit-interface, publishing it, then removing the new image and publishing again. After a recycle of the appPool, that seems to have solved the issue for that particular variant. But given that the issue happens for every newly created variant with a new asset, and that it has already happened for well over 1000 variants, that seems like an unsustainable solution.
Has anyone seen something like this before?
CMS-version 11.12
Commerce-version 12.11
InRiver PIM 6.3 SP3. (on premise version)