This content is archived. See latest version here

Last updated: Mar 31 2014

Introduction

This document describes how to use a CMS-style rendering template in EPiServer Commerce.

Defining content types

To use a CMS-style rendering template for CatalogNode/CatalogEntry, you need to define a new content type for each Metadata class of your CatalogNode/CatalogEntry.

C#
using EPiServer.Commerce.Catalog.ContentTypes;
using EPiServer.Commerce.Catalog.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAnnotations;

namespace CodeSamples.EPiServer.Commerce.Catalog.Provider
{
    [CatalogContentType]
    public class CatalogContentTypeSample : VariationContent
    {
        [CultureSpecific]
        [Tokenize]
        [Encrypted]
        [UseInComparison]
        [IncludeValuesInSearchResults]
        [IncludeInDefaultSearch]
        [SortableInSearchResults]
        public virtual string Description { get; set; }

        public virtual int Size { get; set; }

        [DecimalSettings(18, 0)]
        public virtual decimal Discount { get; set; }
    }
}

For more information about defining content types, see Working with the catalog as IContent.

Defining templates

If you want to display a catalog item on your site, you can do so by creating a template in the same way as it would be done with CMS content. Notice that for the properties CurrentPage and CurrentContent, since the catalog is routed as a partial route to the CMS route, the CurrentPage will give you the PageData that the route is registered under. Default for that would be the start page of the site. CurrentContent would be the requested catalog content.

For more detailed information regarding templating, refer to the Pages and Blocks section in the EPiServer CMS Developer Guide.

Registering new routing

To use new renderer template, you need to register the catalog content routes. The recommended way is to do it in an EPiServer.Framework.IInitializableModule using the CatalogRouteHelper. Refer to the Routing section of the EPiServer Commerce SDK/Developer Guide.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/