How to adjust Relationship Defaults in Episerver Commerce
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.