My client has products that have a large number of properties – for example:
Given there are over a 100 of these (and there could be more in the future) – rather define these as individual properties in my class, can this be done in a more dynamic way?
Ideally we want to be able to allow Commerce Managers to enter these facilities repeatedly, giving each one a name, selecting a data type and then providing the value. This way they could add as many as they liked without the need to recompile/redeploy code.
Have you come across anything like this – is it even possible?
This is not supported by default in Commerce, but nothing prevent you from doing it by code.
You can use a small tool to read from the product definition file (a CVS, may be), then create a MetaField for each field, then add it to the MetaClass of products. APIs can be found here:
Any chance you could post some example code?
I undertsand that basically my models are connected to a MetaClass through the inheriting the appropriate type in the EPiServer.Commerce.Catalog.ContentTypes namespace and decorate it with the CatalogContentTypeAttribute attribute.
So what you suggestinng won't affect my model classes directly - how then could I access these created MetaFields if I wanted to display them on a product details page?
Also - we'd have to roll ouur own editor interface as well so that an editor could control through EPiServer?
No, After you update the metafield, you just need to restart your site and then the properties will be available in your catalog content. Allthough you will need to access via content.Property["MetafieldName"] instead of strongly typed type, like content.MetafieldName.
The only way to have strongly typed type is to auto-generate the content types, then build.
And no, all properties will be available in Catalog Ui without additional modification.
You might need to contact our support service for sample code.
I think I understand ... the order of events would be:
Thats definately a solution - but could the MetaField be added through the Catalog UI perhaps as some kind of collection MetaField?
So an editor opens a product, and next to an "Options" or Properties field, there's an input box "Add" button where they can add multiple ones at the same time.
Something similar to this:
No, the Catalog UI is for editing only, while what you want to do is administration.
Of course there is nothing prevent you from implementation custom widgets for Catalog UI to do that - but I doubt it will be worth it.
Where can I find information custom widgets?
Some links I can find: