The functionality is demonstrated in the Optimizely Customized Commerce sample site on the **Assets** tab for catalog content, where users can define a set of assets to display.
EntryContentBase and NodeContent implements IAssetContainer, which contains the property CommerceMediaCollection. Content that implements the interface IAssetContainer can contain several assets.
In many cases, you can define several asset items for a catalog item, but only one is shown on the site. By default, the first item is used in the asset collection in the catalog UI, ordered by the SortOrder property. You can change this behavior for content types. By adding a type to the AssetUrlConventions class, you can set a default group for the specific content type. Assets in this group are always more important than assets in other groups, regardless of sort order.
The GetAssetUrl method gets the default asset for content. The collection of assets is ordered by SortOrder. The first item in the list is selected, which is in the specified default group for the content. If there is no default group, or there is no asset for the default group, the first item in the list is used.
The AssetUrlConventions class can specify a default asset for a content type. The generic AddDefaultGroup(string groupName) method adds the specified group name as the default group for the generic type, which has to implement IAssetContainer.
You can have only one default group name for each specific content type. An InvalidOperationException is thrown if several default groups are set for the same content type.
GetDefaultGroup gets the default group for the content. This method checks for the exact type, if there is a default group on that level. If there is no registered default group specified on the exact type, the method checks the base class for any default group registered on that type. The method recursively checks for a registered type until it is found, or until the base type no longer implements IAssetContainer.