To display products in the website, a page should be created of type IProductCatalogPage. This article explains creating the product catalog page both using back-office and also programmatically.
To show products in CMS module, a special pagetype called a "Product Catalog Page Type" is needed.
Creating the page type in backoffice
In the Control Panel > Web Publishing > Pagetypes and Templates, click the new pagetype menu option and create the page type with the type "Product Catalog".

The product catalog pagetypes do not have templates in CMS module. Instead they use the display template in the product catalog module based on the product group and the articles.
Creating the product catalog page type programmatically
Following code demonstrates how we can do the same operation as above programmatically.
/// <summary>
/// Creates the product catalog page.
/// </summary>
/// <param name="pageTypeName">Name of the page type.</param>
/// <param name="websiteName">Name of the website.</param>
/// <param name="token">The token.</param>
/// <returns></returns>
public static PageType CreateProductCatalogPage(string pageTypeName, string websiteName, SecurityToken token)
{
var pageType = ModuleCMS.Instance.PageTypes.GetPageType(pageTypeName);
if (pageType != null && pageType.PageTypeCategory != PageTypeCategories.PRODUCT_CATALOG)
{
//page type with same name exists as a regular page., delete it !
pageType.Delete(token);
pageType = null;
}
if (pageType == null)
{
pageType = ModuleCMS.Instance.PageTypes.CreateProductCatalogPageType(
Guid.NewGuid(), //page type id.
pageTypeName,
true, //can be archived
false, //can be versioned
true, //can move to trashcan
true, //can be in Menu
true, //can be in sitemap
false, //can be in visit statistics
true, //can be linked to
true, //can be printed
true, //can be searched
0, //auto archive in weeks.
0, //versions to keep
true, //editable in GUI
null, //edit page
null, //content panel
null, //settings panel
true, //can delete pagetype
true, //can be master page.
null, //possible child pagetypes, this must be false, since a product catalog page will not have childpages.
ModuleCMS.Instance.PageTypes.GetAllPageTypes(), //possible parent page types
new List<WebSite>() { ModuleCMS.Instance.WebSites.GetWebSite(websiteName) }, //list of websites
false, //use secure connection.
token);
}
//set the name for all languages.
Solution.Instance.Languages.GetAllLanguages().ForEach(x=>pageType.SetShortName(pageTypeName, x.ID, token));
return pageType;
}
Adding a product catalog page to the website
Once the page type is available it is possible to create product catalog pages in the website.

This page can be created programatically as follows:
/// <summary>
/// Creates the product catalog page.
/// </summary>
/// <param name="parentPage">The parent page.</param>
/// <param name="pageName">Name of the page.</param>
/// <param name="productGroupId">The product group id.</param>
/// <param name="token">The token.</param>
/// <returns></returns>
public static Page CreateProductCatalogPage(Page parentPage, string pagetypeName, string pageName, Guid productGroupId, SecurityToken token)
{
//check whether a page already exists
//note that we are using the AdminToken here, so that we get all the pages.
Page page = parentPage.Children.GetPage(pageName, ModuleCMS.Instance.AdminToken);
//TODO:
//if the page is found in the above parentPage.Children.GetPage call,
//then its better to check whether page is in archive or trashcan and take an appropriate decision.
//if the page is not found, create it.
if (page == null)
{
var productCatalogPageType = ModuleCMS.Instance.PageTypes.GetPageType(pagetypeName);
page = parentPage.Children.CreatePage(productCatalogPageType, null, pageName, true, token);
page.SetMenuStatus(MenuStatus.VISIBLE_ENABLED_IN_MENU, token);
}
var productCatalogPage = page as IProductCatalogPage;
if (productCatalogPage != null)
{
//we set the product group id here.
if (productCatalogPage.ProductGroupID != productGroupId)
productCatalogPage.SetProductGroupID(productGroupId, token);
//for this example, the language is set to be the same as website language.
if (productCatalogPage.ProductCatalogLanguageID != parentPage.WebSite.Language.ID)
productCatalogPage.SetProductCatalogLanguageID(parentPage.WebSite.Language.ID, token);
//show the products from sub product groups as well.
if (!productCatalogPage.ShowProductGroupRecursively)
productCatalogPage.SetShowProductGroupRecursively(true, token);
}
return page;
}
Note how the product catalog information is set in above code by casting the page into an IProductCatalogPage interface.