November Happy Hour will be moved to Thursday December 5th.

Updating non-CultureSpecific fields using ServiceApi

Vote:
 

We are trying to update an Entry with several properties of which some are CultureSpecific and others are not.

Basically we take the following steps to update an Entry:

  1. Retrieve an Entry using the code value using the endpoint GET /episerverapi/commerce/entries/{entryCode}
  2. Deserialize the json result into a Entry DTO in code
  3. Update the relevant fields in the Entry DTO
  4. Update the Entry by serializing the updated Entry DTO and send it using the endpoint PUT /episerverapi/commerce/entries/{entryCode}

But if you look at the json result of the GET endpoint, ALL MetaFields are returned with ALL languages whether or not the value they represent is CultureSpecific or not.

Once we try updating the Entry, we get several warnings for non-CultureSpecific fields like the following:

warn: EPiServer.Commerce.Catalog.Provider.Persistence.MetaDataCommitter[0]
      Non culture-specific property ProductType is changed in language fr-FR, which is not the master language. The change will not be saved to database.

We have 12 languages in the application in question, so we are getting A LOT of these warnings.

Is there any way to avoid this warning?

Thanks for any help/tips!

Stephen

#312477
Nov 13, 2023 21:15
Vote:
 

one possible approach is when you update the Entry, you can have check like this (pseudo code)

if (!property.CultureSpecific && entry.Language != entry.MasterLanguage) 

{

continue;

}

the check was added by me long ago because we had several cases when customers complained that the changes were not saved - turned out they were trying to update content in non master language.

#312478
Nov 13, 2023 21:51
Vote:
 

Sure but I am updating via a PUT request in the REST Api ... I don't have the option to check the language as you are suggesting.

One idea that came to mind was to not include the non-master languages from the original GET request. For example, here is a small sample of the result I get from the GET request:

{
  "IsActive": true,
  "MetaFields": [
    {
      "Data": [
        {
          "Language": "en",
          "Value": "Wheelchair"
        },
        {
          "Language": "fr-FR",
          "Value": ""
        },
		{
          "Language": "de-DE",
          "Value": ""
        },
        {
          "Language": "en-CA",
          "Value": ""
        }
	  ],
	  "Name": "WebCategory",
      "Type": "ShortString"
    }

I've tried updating with the PUT request and remoing the non-master languages as follow:

{
  "IsActive": true,
  "MetaFields": [
    {
      "Data": [
        {
          "Language": "en",
          "Value": "Wheelchair UPDATED"
        }
      ],
      "Name": "WebCategory",
      "Type": "ShortString"
    }

But I still get the warning Non culture-specific property ProductType is changed in language fr-FR

 

#312515
Edited, Nov 14, 2023 7:03
Vote:
 

You are right. I checked ServiceAPI code and it seems it will try to update those non specific properties in non master language. I created bug COM-17457 to address that. I will try to submit a fix to the commerce team but there is currently no work around available I'm afraid. 

#312517
Nov 14, 2023 7:33
Vote:
 

Just curious, when will I see COM-17457 appear in the bug list? https://world.optimizely.com/support/Bug-list/bug/COM-17457

#312634
Nov 16, 2023 9:19
Vote:
 

It will take some time. As I am no longer part of Commerce team I entrust them with the triage process. 

#312636
Nov 16, 2023 9:42
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.