Flexible property definition on Products

Vote:
 

My client has products that have a large number of properties – for example:

Property

Data Type

Adult only

True/False

Dogs allowed

True/False

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?

#131304
Jul 20, 2015 17:24
Vote:
 

Hi,

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:

http://world.episerver.com/documentation/Class-library/?documentId=commerce/7.5/A8B3DF01 

http://world.episerver.com/documentation/Class-library/?documentId=commerce/7.5/276E6271

Regards.

/Q

#131306
Jul 20, 2015 18:50
Vote:
 

Thanks Q,

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?

Regards

Neil

#131342
Jul 21, 2015 13:39
Vote:
 

Hi,

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.

Regards.

/Q

#131346
Jul 21, 2015 14:15
Vote:
 

Thanks Q 

I think I understand ... the order of events would be:

  • Use the custom tool to read a file of properties and update the MetaClass first.
  • Then, after restart, when viewing the product in the Catalog UI, all these new fields wouold be rendered as normal.

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:

Sample

#131353
Jul 21, 2015 17:31
Vote:
 

Hi,

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.

Regards.

/Q

#131377
Jul 22, 2015 13:11
Vote:
 

Q,

Where can I find information custom widgets?

Regards

#131420
Jul 23, 2015 18:31
Vote:
 

Some links I can find:

http://world.episerver.com/blogs/Linus-Ekstrom/Dates/2014/4/Adding-custom-views-to-your-content/

http://tedgustaf.com/blog/2014/6/create-an-episerver-widget-for-edit-mode/ 

Regards,

/Q

#131421
Jul 23, 2015 18:36
* 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.