Categorization of Content in Episerver Commerce

casper.rasmussen/ May 3, 2016/ Content Types and Properties, Episerver Commerce/ 0 comments

Episerver has supported content tagging and categorization since the introduction of Episerver CMS 5. From Episerver CMS 7 and onward, it has been supported via the ICategorizable interface requiring your type to implement a Category property. It means that we can easily use the Category property across all types of Content – or does it?

I’ve seen many client requirements being dependent on the need for tagging and categorizing content – e.g. to give the needed flexibility to control parameters for content drilling. During projects, we’ve had the need to associate Commerce related content to a range of Categories. This is where you will get into trouble. Luckily, the solution is simple and self-explanatory.

So.. whats wrong?

Episerver Commerce is integrated into the authoring experience via dedicated content providers acting as the bridge between IContent and Meta Data Plus. It does mean, that we are still dependent on the capabilities of Meta Data Plus and the types available in the underlying Catalogue System.
The reason why we are meeting an error is because Meta Data Plus does not understand the type ‘CategoryList’. So the fix is simple, let’s give Meta Data Plus a type that it understands.

Tell Commerce to support CategoryList

Episerver allows developers to define a Backing Type. It tells the system how a property, e.g. of type custom type (like CategoryList), should be treated as a supported property type. In our scenario, we want to force Episerver to save the CategoryList property as a type supported by Meta Data Plus.

Above snippet is our proxy type used when Episerver is requested to e.g. save our CategoryList property. It specifies, via the Type property, that it should be persisted as a String. Be aware that the out-of-the-box CategoryList already supports to be re-created via a String. It means that we are not doing anything funky in order to “stringify” it.

In order to use the Backing Type in Commerce, simply specify it as part of any CategoryList property.

Be aware that you cannot implement the previously mentioned interface ICategorizable in Episerver Commerce. It will get confused when constructing the model types.

Leave a Comment

Your email address will not be published. Required fields are marked *

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*