vc-module-catalog
vc-module-catalog copied to clipboard
PropertyValues depreciated in V3
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?
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" }