Try our conversational search powered by Generative AI!

Change Non Culture-Specific Property from Any Language


We have an issue where we want to change a non culture-specific property from any language for a product or variant.

This property needs to still be the same for any language as it's not translatable, but based on data we receive from an API for different languages we need to continuously update it.

Right now when we try to save to that property from another language, the property doesn't update. It only updates from code when we are on the master language for a product/variant. We could switch to the master language after saving data against another language, but that isn't very efficient.

Is there any way to change a non culture-specific property on a product/variant from a non master-language version?

Aug 11, 2018 17:02

Unfortunately there is not. The master language would need to be loaded anyway.

Aug 11, 2018 22:21

What about updating the Metafield directly? That's what I've been trying to do since I put this post up, but my code isn't working. It's not updating the Metafield. It's a PropertyList in case that matters. Here's the code I've been trying to use so far, but it doesn't save the data to the master language record for the product. Am I missing something here?

        private MetaDataContext GetMetaDataContext(string language)
            MetaDataContext metaDataContext = CatalogContext.MetaDataContext.Clone();
            metaDataContext.Language = language.ToLower(CultureInfo.InvariantCulture);
            return metaDataContext;
        private void UpdateAllowedMarkets(Product epiProduct, string market)
            IObjectSerializer serializer = _objectSerializerFactory.Service.GetSerializer("application/json");

            MetaDataContext metaDataContext = this.GetMetaDataContext("en");
            MetaClass metaClass = MetaClass.Load(metaDataContext, epiProduct.MetaClassId);

            MetaObject metaObject = MetaObject.Load(metaDataContext, epiProduct.ContentLink.ID, epiProduct.MetaClassId);
            MetaObject metaObj = metaObject == null ? new MetaObject(metaClass, epiProduct.ContentLink.ID) : MetaObject.Clone(metaObject);

            metaObj["PropertyName"] = (object)serializer.Serialize(epiProduct.AllowedMarkets);

            metaObj.DisableSync = true;
Aug 11, 2018 23:21

I would advise against using metaobject directly if it is not the last resort. It has very small performance gain and can be very problematic with special types of data - for example PropertyList as yours. If you still want to go that path, your MetaDataContext does not have UseCurrentThreadCulture as false, which is required.

Aug 11, 2018 23:26
* 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.