vc-module-catalog icon indicating copy to clipboard operation
vc-module-catalog copied to clipboard

PropertyValues depreciated in V3

Open Woland2k opened this issue 4 years ago • 1 comments

I can see that PropertyValues was depreciated for the CatalogProduct class in V3:

        [Obsolete("it's for importing data from v.2, need to use values in Properties")]
        public ICollection<PropertyValue> PropertyValues { get; set; }

So what is the way to just add values to the product without necessary creating corresponding property?

Woland2k avatar Apr 01 '20 22:04 Woland2k

So to change a property value for the product you need to use the product.properties collection instead

product.Properties.FirstOrDefault(x => x.Name.EqualsInvariant("color"))?.Values = new [] { new PropertyValue { Value = "foo" }; 

We need to add some better fluent syntax to do that from code, I'll create some task into our internal backlog.

Ween need to do it something like this

product.Properties["color"] = "foo";
product.Properties["some_array"] = new [] { "foo", "boo" };
product.Properties["some_dict"] = new PropertyDictionaryItem { ... }
product.Properties["some_flag"] = true
product.Properties["some_datetime"] = DateTime.UtcNow();
product.Properties["some_muti_lang"] = new LocalizedString { Lang = "en-US", Value = "red" }

tatarincev avatar Apr 09 '20 10:04 tatarincev