Class CategoryFieldViewModel
- Namespace
- Dynamicweb.Ecommerce.ProductCatalog
- Assembly
- Dynamicweb.Ecommerce.dll
Represents a view model for a product category (field group) and its associated field values.
public class CategoryFieldViewModel : FillableViewModelBase
- Inheritance
-
CategoryFieldViewModel
- Inherited Members
Remarks
In Dynamicweb, product categories are named groups of custom fields attached to products (e.g. "Dimensions",
"Technical Specifications"). Each category is represented by this view model and exposes its fields as a
keyed dictionary of FieldValueViewModel instances, where the key is the field system name.
In Razor templates, iterate Fields to render all fields in a category:
@foreach (var category in Model.Product.CategoryFields)
{
<h3>@category.Name</h3>
@foreach (var field in category.Fields)
{
<p>@field.Value.Name: @field.Value.Value</p>
}
}
Properties
Fields
Gets or sets the field values belonging to this category, keyed by field system name. Each value is a FieldValueViewModel that exposes the field name, type, and value. Returns null when the property was not requested via the view model settings.
public Dictionary<string, FieldValueViewModel> Fields { get; set; }
Property Value
Id
Gets or sets the unique identifier of the product category (e.g. "EcomProductCategoryFieldCategory5").
public string Id { get; set; }
Property Value
Name
Gets or sets the display name of the product category shown as a group heading in the template (e.g. "Dimensions").
public string Name { get; set; }