Table of Contents

Class ProductViewModelExtensions

Namespace
Dynamicweb.Ecommerce.ProductCatalog
Assembly
Dynamicweb.Ecommerce.dll
public static class ProductViewModelExtensions
Inheritance
ProductViewModelExtensions
Inherited Members

Methods

BackInStockRegisteredForUser(ProductViewModel, string, long)

Checks if the product is registered for back-in-stock notifications for the current user

public static bool BackInStockRegisteredForUser(this ProductViewModel product, string unitId = "", long stocklocationId = 0)

Parameters

product ProductViewModel

The product view model

unitId string

The unit ID of the product

stocklocationId long

The stock location ID

Returns

bool

True if the product is registered for back-in-stock notifications, false otherwise

GetAssetsList(ProductViewModel, IEnumerable<string>, bool)

Gets product assets with only supported file formats and image patterns

public static IEnumerable<MediaViewModel> GetAssetsList(this ProductViewModel productViewModel, IEnumerable<string> selectedAssetsCategories, bool includeImagePatterns)

Parameters

productViewModel ProductViewModel

The product view model

selectedAssetsCategories IEnumerable<string>

The selected asset categories

includeImagePatterns bool

Flag indicating whether to include image patterns

Returns

IEnumerable<MediaViewModel>

The list of product assets

GetBomConfiguration(ProductViewModel)

Gets the bill of materials (BOM) configuration of the product

public static BomConfigurationViewModel GetBomConfiguration(this ProductViewModel productViewModel)

Parameters

productViewModel ProductViewModel

The product view model

Returns

BomConfigurationViewModel

The BOM configuration

GetPrice(ProductViewModel)

Gets the price information of the product

public static PriceInfoViewModel GetPrice(this ProductViewModel productViewModel)

Parameters

productViewModel ProductViewModel

The product view model

Returns

PriceInfoViewModel

The price information

GetPrice(ProductViewModel, string)

Gets the price information of the product for the specified unit

public static PriceInfoViewModel GetPrice(this ProductViewModel productViewModel, string unitId)

Parameters

productViewModel ProductViewModel

The product view model

unitId string

The unit ID

Returns

PriceInfoViewModel

The price information

GetPrice(ProductViewModel, string, long)

Gets the price information of the product for the specified unit and stock location

public static PriceInfoViewModel GetPrice(this ProductViewModel productViewModel, string unitId, long stockLocationId)

Parameters

productViewModel ProductViewModel

The product view model

unitId string

The unit ID

stockLocationId long

The stock location ID

Returns

PriceInfoViewModel

The price information

GetProductDisplayGroupFieldsByGroupSystemNames(ProductViewModel, IEnumerable<string>, bool)

Gets the product display group fields by group system names

public static IEnumerable<FieldGroupViewModel> GetProductDisplayGroupFieldsByGroupSystemNames(this ProductViewModel productModel, IEnumerable<string> groupSystemNames, bool hideZeroValues = false)

Parameters

productModel ProductViewModel

The product view model

groupSystemNames IEnumerable<string>

The group system names

hideZeroValues bool

Flag indicating whether to hide zero values

Returns

IEnumerable<FieldGroupViewModel>

The product display group fields

Gets the primary link to a given product using its default group id and that groups primary page id if that is specified - otherwise the specified page id.

public static string GetProductLink(this ProductViewModel product, int pageId, bool usePrimaryGroupPageId = true)

Parameters

product ProductViewModel

The product view model

pageId int

The page ID

usePrimaryGroupPageId bool

Flag indicating whether to use the primary group's page ID

Returns

string

The primary link to the product

If a product is member of 2 or more groups, the group specified as primary group or the default group in this shop context will be used to create the link. When the product is shown in 2 different group contexts, the link will be created using the group id specified in the parameter of the page and the link will be the same in both scenarios If a group context aware link is required, use the overload with the current group id.GetProductLink(ProductViewModel, int, string, bool)

Gets the primary link to a given product using the current group context and that groups primary page id if that is specified.

public static string GetProductLink(this ProductViewModel product, int pageId, string currentGroupId, bool usePrimaryGroupPageId = true)

Parameters

product ProductViewModel

The product view model

pageId int

The page ID

currentGroupId string

The current group ID

usePrimaryGroupPageId bool

Flag indicating whether to use the primary group's page ID

Returns

string

The link to the product using the group id of the current group context

If a product is member of 2 or more groups and you want to show the product in the context of the current group and not its primary group, use this overload. If the current group matches one of the groups the product belong to the link will be created using the group id specified in the currentGroupId parameter. Otherwise the products subgroups are matched to see if one fits, and then the subgroup id is used if it matches the currentGroupId.

GetRelatedProducts(ProductViewModel)

Gets a collection of related products from all related groups

public static IEnumerable<ProductViewModel> GetRelatedProducts(this ProductViewModel product)

Parameters

product ProductViewModel

The product view model

Returns

IEnumerable<ProductViewModel>

The collection of related products

HasDiscount(ProductViewModel)

Determines whether the product has a discount (discount value > 0).

public static bool HasDiscount(this ProductViewModel productViewModel)

Parameters

productViewModel ProductViewModel

The product view model.

Returns

bool

True if a discount exists and its price value is greater than 0; otherwise false.

IsProductInCart(ProductViewModel, string)

Checks if the product is in the cart

public static bool IsProductInCart(this ProductViewModel product, string orderContextId = null)

Parameters

product ProductViewModel

The product view model

orderContextId string

The order context ID

Returns

bool

True if the product is in the cart, false otherwise

TryGetAssetsList(ProductViewModel, IEnumerable<string>, bool, out IEnumerable<MediaViewModel>)

Tries to get product assets with only supported file formats and image patterns

public static bool TryGetAssetsList(this ProductViewModel productViewModel, IEnumerable<string> selectedAssetsCategories, bool includeImagePatterns, out IEnumerable<MediaViewModel> assetsList)

Parameters

productViewModel ProductViewModel

The product view model

selectedAssetsCategories IEnumerable<string>

The selected asset categories

includeImagePatterns bool

Flag indicating whether to include image patterns

assetsList IEnumerable<MediaViewModel>

The list of product assets

Returns

bool

True if the assets list is not empty, false otherwise

VariantCombinations(ProductViewModel)

Gets the variant combinations of the product

public static List<string> VariantCombinations(this ProductViewModel productViewModel)

Parameters

productViewModel ProductViewModel

The product view model

Returns

List<string>

The list of variant combinations

VariantGroups(ProductViewModel)

Gets the variant groups of the product

public static List<VariantGroupViewModel> VariantGroups(this ProductViewModel productViewModel)

Parameters

productViewModel ProductViewModel

The product view model

Returns

List<VariantGroupViewModel>

The list of variant groups

To top