Table of Contents

Class ProductListViewModel

Namespace
Dynamicweb.Ecommerce.ProductCatalog
Assembly
Dynamicweb.Ecommerce.dll

The top-level view model for a product list page — contains the products, the active group, sub-groups, facets, pagination data, and spell-checker suggestions.

public class ProductListViewModel : FillableViewModelBase
Inheritance
ProductListViewModel
Inherited Members
Extension Methods

Remarks

This is the primary model rendered by product list templates. A minimal Razor usage pattern:

@foreach (var product in Model.Products)
{
    <a href="@product.GetProductLink(Dynamicweb.Frontend.PageView.Current().ID)">
        @product.Name
    </a>
}
@* Pagination *@
@for (int p = 1; p <= Model.PageCount; p++)
{
    <a href="?PageNum=@p">@p</a>
}

Use ProductListViewModelExtensions for helpers such as GetUriWithoutSelectedFacets(ProductListViewModel) and GetSubOrRootGroups(ProductListViewModel).

Properties

CurrentPage

Gets or sets the 1-based current page number (e.g. 1 for the first page).

public int CurrentPage { get; set; }

Property Value

int

FacetGroups

Gets or sets the facet groups available for the current search result. null when facets were not requested via settings. Iterate over this to render filter sidebars; use GetUriWithoutSelectedFacets(ProductListViewModel) to build a "Clear all filters" link.

public IList<FacetGroupViewModel> FacetGroups { get; set; }

Property Value

IList<FacetGroupViewModel>

Group

Gets or sets the product group currently being browsed. Populated when the request includes a GroupID query parameter (e.g. ?GroupID=group1). null for pure search results (e.g. ?q=shirt) where no group context exists.

public ProductGroupViewModel Group { get; set; }

Property Value

ProductGroupViewModel

PageCount

Gets or sets the total number of pages in the result set. 0 or 1 means the result is not paginated.

public int PageCount { get; set; }

Property Value

int

PageSize

Gets or sets the number of products per page as configured in the catalog paragraph. 0 means all products are returned without pagination.

public int PageSize { get; set; }

Property Value

int

Products

Gets or sets the products on the current page of the result set. null when the Products property was not requested via settings.

public IList<ProductViewModel> Products { get; set; }

Property Value

IList<ProductViewModel>

SortBy

Gets or sets the index field name by which the list is currently sorted. When sorted by multiple fields only the primary field is exposed here.

public string SortBy { get; set; }

Property Value

string

SortOrder

Gets or sets the sort direction for the primary sort field — typically "ASC" or "DESC". When sorted by multiple fields only the primary sort direction is exposed here.

public string SortOrder { get; set; }

Property Value

string

SpellCheckerSuggestions

Gets or sets the spell-checker alternative search terms returned when the search query produced few or no results. Empty when no suggestions are available.

public IList<string> SpellCheckerSuggestions { get; set; }

Property Value

IList<string>

SubGroups

Gets or sets the direct child groups of Group. Empty when the current group has no sub-groups or when browsing a search result. Use GetSubOrRootGroups(ProductListViewModel) to fall back to shop root groups when no sub-groups exist.

public IList<ProductGroupViewModel> SubGroups { get; set; }

Property Value

IList<ProductGroupViewModel>

TotalProductsCount

Gets or sets the total number of products across all pages in the result set. Use this to display a "Showing X of Y products" message.

public int TotalProductsCount { get; set; }

Property Value

int

See Also

To top