This content is archived. See latest version here

Last updated: Oct 21 2014

This document describes how to render catalog content 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. The example below shows a simple content type for a product variant.

using System;
using System.ComponentModel.DataAnnotations;
using EPiServer.Commerce.Catalog.ContentTypes;
using EPiServer.Commerce.Catalog.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.SpecializedProperties;

namespace MyCommerceSite.Models.Catalog
{
    [CatalogContentType(GUID = "8d664789-3e96-409e-b418-baf807241f7c", MetaClassName = "My_Variation")]
    public class MyVariation : VariationContent
    {

    }
}

For more information about defining content types, see Catalog content.

Defining rendering templates

You can display Commerce catalog content on your website by creating a rendering template (MVC/WebForms) in the same way as you would for CMS content. The example below shows a simple controller for a product variant.

using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework.DataAnnotations;
using EPiServer.Web.Mvc;
using MyCommerceSite.Models.Catalog;

namespace MyCommerceSite.Controllers
{
    public class MyVariationController : ContentController<MyVariation>
    {
        public ActionResult Index(MyVariation currentContent)
        {
            return View(currentContent);
        }
    }

}

Note 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. However, for Commerce content, currentContent would be the requested catalog content.

For more information regarding templating, see Rendering in the CMS Developer Guide.

Registering new routing

To use a 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, see  Routing for more information.


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/