How to adjust Relationship Defaults in Episerver Commerce

casper.rasmussen/ May 14, 2016/ Episerver Commerce/ 3 comments

Adjusting default conventions for e.g. Asset Groups and Related Entry Types does not seem to be very well documented by Episerver. For that reason, I quickly want to cover those adjustment options here along with an example in order to provide some inspiration and context on the subject.

It is a very simple exercise, so let us jump right in to it.

Adjust the Default Asset Group

Episerver’s go-to class for Asset conventions is EPiServer.Commerce.Catalog.AssetUrlConventions. It helps Commerce decide the defaults for e.g. the Asset Group and Asset Urls. We can simply adjust the behaviour as part of an Episerver Initialization Module:

I am, in above snippet, setting the default Group to “Image” for all my product types. It is possible to adjust this on a per-type basis. Be aware that the default implementation also can be replaced via Structuremap. It could be relevant in case you have any need for additional flexibility or business logic.

Example on when to use Asset Groups
A recent client-project required us to act differently based on the grouping of Assets. We predefined, by convention, “Image”, “Video” and “Resource” in order to determine if an asset were supposed to be presented as part of the Image and Video Library or our Documentation section of any given product. Type of Asset – e.g. .pdf or DocumentMediaFileType – where not sufficient due to a requirement being that Images could be Documentation in form of Drawings.

Configure available Types for Related Entries
Structuring your relationship between products is powerful and are a basic prerequisite on most e-commerce implementations. It is easy to support other options than the out-of-the-box “Default” option.

Again, we are utilizing an Episerver Initialization Module to do the needed adjustment.

Example on when to use grouping Related Entries
Related Entries are, in some of my previous projects, both a representation of Related Products, Product Accessories and Product Parts. Defining a set of Groups enables our Catalog Managers to define the type of relationship – i.e. if a given product is a Related Product or an Accessory. It is important information when having to present Related Products individually from Product Parts or when Product Recommendations or Content Segmentation is implemented based on user state/behavior.

Again.. it’s a simple adjustment that could be helpful for both new and existing Episerver Commerce enthusiasts.


  1. This looks all cool, but I’m curious to learn how/when to use it? I guess there is something in “the other end” that benefit from this. Can you elaborate on examples for this?

    1. Hi Johan.

      I’ve added an example for each of the adjustsments. These examples reflect real-life requirements set by Clients.

      Hope that provided you with the context needed.

      Casper Aagaard Rasmussen

  2. I’m surprised how little documentation there is for problematically configuring the association types. Was pleased to come across your post!

    I realise I would likely be a couple of commerce versions ahead of you (v11). But I’m finding that the “Default” is never really deleted with this code. When I add a new relation it always starts with type “Default” still, if I hit the dropdown it only shows my new custom value – and once I change to this you can’t select “Default” again.. But this is messy since all new entries start with “Default”.

    And, upon closer inspection, I realise that it is storing the new association types in the DDS.

    Curious if you know any more about what I might be getting wrong? If not, I’ll go post on the World forums.

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>