- Business Foundation
- Generating typed business foundation classes
- SQL Meta Model
- Extending meta models
- Exporting and importing meta models
- Working with SQL Records
- Working with entity objects
- Filtering and sorting
- Business Meta Model
- Product variants
- Bundles and packages
- Related entries
- Catalog events
- Commerce rendering templates
- Catalog content provider
- Content-based campaigns
- Assets and media
- Meta Data Plus
- Scheduled Jobs
- Warehouses and inventories
This content is archived. See latest version here
Last updated: Dec 08 2014
Asset URL resolver
This document briefly describes how the display of assets for catalog content can be implemented using the AssetUrlResolver and the AssetContainer interface. The functionality is demonstrated in the EPiServer Commerce sample site, on the Assets tab for catalog content, where users can define a set of assets to be displayed.
How it works
EntryContentBase and NodeContent implements IAssetContainer, which contains the property CommerceMediaCollection. Content which implements the interface IAssetContainer can contain several assets.
In many cases, several asset items can be defined for a catalog item, but only one will be shown on the site. By default, the first item in the asset collection, ordered by the property "SortOrder", will be used in the catalog UI. This behavior can be changed for content types. By adding a type to the class "AssetUrlConventions", a default group can be set for the specific content type. Assets in this group will then always be more important than assets in other groups, regardless of the sort order.
The method "GetAssetUrl" will get the "default" asset for content. The collection of assets will be ordered by "SortOrder". The first item in the list which is in the specified default group for the content, will be selected. If there is no default group, or there is no asset for the default group, the first item in the list will be used.
The class AssetUrlConventions can be used to specify a default asset for a content type. The generic method AddDefaultGroup(string groupName) will add the specified group name as the default group for the generic type, which has to implement IAssetContainer.
There can only be one default group name for each specific content type. An InvalidOperationException will be thrown if there are several default groups defined to be set for the same content type.
GetDefaultGroup will get the default group for the content. This method will start to look at 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 will look at the base class to see if there is any default group registered on that type. The method will recursively look for a registered type until it is found, or until the base type does not implement IAssetContainer anymore.
- Assets and media for Commerce content