3. Creating a start page
In this step, we
- Create a start page page type in CMS, with rendering based on MVC and the Episerver content model.
- Configure the site's start page.
- Add components to display catalog content.
We assume that you are using the Episerver Visual Studio extension.
Note: You must be a site administrator to create a start page under the website root.
Creating the start page page type
Follow the steps under Creating a page type, Adding page rendering and Configuring the start page in Create a starter project for CMS to create a start page page type with a controller and a view on the front-end site of your Commerce solution. After completing this, you have a website with a working start page.
Creating content types for category, product and variant
These steps create simple content types for a category node, a product, and a variant (SKU). This allows you to add catalog entries from the catalog user interface, the foundation of the catalog structure.
- Right-click the Models folder, select Add > New Folder, and name it Catalog.
- Right-click Catalog, select Add > New Item, then EPiServer and Page Type.
- Name the item MyNode.cs and click Add. This will be a category content type.
- Change ContentType to CatalogContentType, remove DisplayName and Description, add MetaClassName = "My_Node", and resolve the using references. This new class should inherit NodeContent.
- Repeat steps 2-4 to add content types for MyProduct and MyVariation. The two new classes should inherit ProductContent and VariationContent.
- Compile the solution.
- Log into the catalog user interface.
- Verify that you can create categories, products and variants based on the created content types.
Note: Since there is no rendering yet, the entries open in the All properties editing view. The content types are very simple with no properties, just to illustrate the content model in Commerce.
Adding controllers and views for catalog entries
These steps add controllers and views for rendering the catalog content types. This works the same way as creating the rendering for CMS content.
- Open the project in Visual Studio, and right-click the Controllers folder.
- Select Add > New Item > Episerver > Page Controller (MVC).
- Name the item MyNodeController.cs and click Add. This will be a category content type controller.
- Change PageController to ContentController and resolve the using references.
Note: For the built-in functionality provided by a model binder in CMS to retrieve the related content, the parameter name must be currentContent.
- Repeat steps 1-4 to add controllers for MyProduct and MyVariation. (Replace MyNode in step 3 by MyProduct and MyVariation respectively.)
- Right-click the Views folder, select Add > New Folder, and name it MyNode.
- Right-click the MyNode folder, select Add > New item, and Page Partial View (MVC Razor) under the Episerver group.
- Name the item Index.cshtml and click Add.
- In the Index.cshtml file, change the model to be YourSite.Models.Catalog.MyNode.
Note: The view is empty at this point, since the MyNode content type has no properties.
- Repeat steps 6-9 to add views for MyProduct and MyVariation. (Replace MyNode in step 6 and 9 by MyProduct and MyVariation respectively.)
- Compile the solution.
- Verify that you have proper rendering (although empty) for your content types.
Do you find this information helpful? Please log in to provide feedback.
Last updated: Oct 11, 2013