Table of Contents

Class ProductCategoryService

Namespace
Dynamicweb.Ecommerce.Products.Categories
Assembly
Dynamicweb.Ecommerce.dll
public class ProductCategoryService : ICacheStorage<string, Category>, ICacheStorage<string>, ICacheStorage
Inheritance
ProductCategoryService
Implements
Inherited Members

Methods

AddFieldToCategory(Category, Field)

Adds a Field to the category. Also adds a language version of the Field to each language version of the category.
public void AddFieldToCategory(Category theCategory, Field field)

Parameters

theCategory Category
field Field
The field to add.

AddFieldToCategory(Category, string, string, string, string, string, FieldListPresentationType, FieldOptionCollection)

Adds a Field to the category. Also adds a language version of the Field to each language version of the category.
public void AddFieldToCategory(Category theCategory, string systemName, string label, string templateTag, string type, string defaultValue, FieldListPresentationType presentation, FieldOptionCollection options)

Parameters

theCategory Category
systemName string
The SystemName of the field.
label string
The Label of the field.
templateTag string
type string
The type of the field.
defaultValue string
presentation FieldListPresentationType
options FieldOptionCollection

AddFieldToCategory(Category, string, string, string, string, string, FieldListPresentationType, FieldOptionCollection, int)

Adds a Field to the category. Also adds a language version of the Field to each language version of the category.
public void AddFieldToCategory(Category theCategory, string systemName, string label, string templateTag, string type, string defaultValue, FieldListPresentationType presentation, FieldOptionCollection options, int sortOrder)

Parameters

theCategory Category
systemName string
The SystemName of the field.
label string
The Label of the field.
templateTag string
type string
The type of the field.
defaultValue string
presentation FieldListPresentationType
options FieldOptionCollection
sortOrder int

AddFieldToCategory(Category, string, string, string, string, string, FieldListPresentationType, FieldOptionCollection, int, string)

Adds a Field to the category. Also adds a language version of the Field to each language version of the category.
public void AddFieldToCategory(Category theCategory, string systemName, string label, string templateTag, string type, string defaultValue, FieldListPresentationType presentation, FieldOptionCollection options, int sortOrder, string description)

Parameters

theCategory Category
systemName string
The SystemName of the field.
label string
The Label of the field.
templateTag string
type string
The type of the field.
defaultValue string
presentation FieldListPresentationType
options FieldOptionCollection
sortOrder int
description string

ClearCache()

Resets all keys to the default value for objects stored in the object cache
public void ClearCache()

ClearCache(LanguageBasedKey<string>)

[Obsolete("Use ClearCache(string key).")]
public void ClearCache(LanguageBasedKey<string> key)

Parameters

key LanguageBasedKey<string>

ClearCache(IEnumerable<LanguageBasedKey<string>>)

[Obsolete("Use ClearCache(IEnumerable<string> keys).")]
public void ClearCache(IEnumerable<LanguageBasedKey<string>> keys)

Parameters

keys IEnumerable<LanguageBasedKey<string>>

ClearCache(IEnumerable<string>)

Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<string> keys)

Parameters

keys IEnumerable<string>
Keys to reset

ClearCache(string)

Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(string key)

Parameters

key string
Key to reset

ClearCategoryCache()

Clears category cache.
public void ClearCategoryCache()

ClearFieldCache()

Clears fields cache.
public void ClearFieldCache()

ConvertFieldOptionsToXml(FieldOptionCollection)

Converts fields options to XML string.
[Obsolete]
public string ConvertFieldOptionsToXml(FieldOptionCollection options)

Parameters

options FieldOptionCollection
The options.

Returns

string

CreateCategory(string)

Creates a new Category object with the given parameters and saves it to the database. In addition a Category object is creates for all current eCommerce Languages. The ID of the object is auto-generated. The Dynamicweb.Ecommerce.International.Language of the object is set to Context.Language.
public Category CreateCategory(string name)

Parameters

name string
The Name of the object.

Returns

Category
The language version of the Category related to the Default Ecommerce Language.

CreateCategory(string, string)

Creates a new Category object with the given parameters and saves it to the database.
public Category CreateCategory(string systemName, string name)

Parameters

systemName string
The SystemName of the object.
name string
The Name of the object.

Returns

Category
The language version of the Category related to the Default Ecommerce Language.

CreateCategory(string, string, CategoryType)

Creates a new Category object with the given parameters and saves it to the database.
public Category CreateCategory(string systemName, string name, CategoryType categoryType)

Parameters

systemName string
The SystemName of the object.
name string
The Name of the object.
categoryType CategoryType
The category type.

Returns

Category

CreateCategory(string, string, CategoryType, Language)

Creates a new Category object with the given parameters and saves it to the database.
[Obsolete("Use CreateCategory(string systemName, string name, CategoryType categoryType) or Category.Translations instead.")]
public Category CreateCategory(string systemName, string name, CategoryType categoryType, Language language)

Parameters

systemName string
The SystemName of the object.
name string
The Name of the object.
categoryType CategoryType
The category type.
language Language
The category language.

Returns

Category
The language version of the Category related to the current Ecommerce Language.

CreateCategory(string, string, bool)

Creates a new Category object with the given parameters and saves it to the database. In addition a Category object is creates for all current eCommerce Languages.
[Obsolete("Use CreateCategory(String, String, CategoryType, Language) instead.")]
public Category CreateCategory(string systemName, string name, bool productProperties)

Parameters

systemName string
The SystemName of the object.
name string
The Name of the object.
productProperties bool
The value indicates whether category is used for product properties.

Returns

Category
The language version of the Category related to the Default Ecommerce Language.

CreateCategory(string, string, bool, Language)

Creates a new Category object with the given parameters and saves it to the database. In addition a Category object is creates for all current eCommerce Languages.
[Obsolete("Use CreateCategory(String, String, CategoryType, Language) instead.")]
public Category CreateCategory(string systemName, string name, bool productProperties, Language language)

Parameters

systemName string
The SystemName of the object.
name string
The Name of the object.
productProperties bool
The value indicates whether category is used for product properties.
language Language
The category language.

Returns

Category
The language version of the Category related to the Default Ecommerce Language.

CreateField(string, Category, string, string, string)

Creates a new Field object.
public Field CreateField(string id, Category category, string templateTag, string label, string type)

Parameters

id string
category Category
templateTag string
label string
type string

Returns

Field

CreateField(string, Category, string, string, string, string, FieldListPresentationType, FieldOptionCollection, string)

Creates a new Field object.
public Field CreateField(string id, Category category, string templateTag, string label, string type, string defaultValue, FieldListPresentationType presentation, FieldOptionCollection options, string description)

Parameters

id string
category Category
templateTag string
label string
type string
defaultValue string
presentation FieldListPresentationType
options FieldOptionCollection
description string

Returns

Field

DeleteCategory(Category)

Deletes the Category and all fields associated, and all language versions.
public void DeleteCategory(Category theCategory)

Parameters

theCategory Category

DeleteCategoryTranslation(Category, string)

public void DeleteCategoryTranslation(Category theCategory, string languageId)

Parameters

theCategory Category
languageId string

DeleteField(Field)

Deletes the field.
public void DeleteField(Field theField)

Parameters

theField Field
The field to remove.

GetCategories()

Returns all categories from database.
public IEnumerable<Category> GetCategories()

Returns

IEnumerable<Category>
A collection of categories containing 0 or more items.

GetCategories(Product)

Gets the Category objects for each of the Group this belongs.
public IEnumerable<Category> GetCategories(Product product)

Parameters

product Product
The product.

Returns

IEnumerable<Category>
A collection of categories containing 0 or more items.

GetCategories(Product, bool)

Gets the Category objects for each of the Group this belongs.
public IEnumerable<Category> GetCategories(Product product, bool includeProductProperties)

Parameters

product Product
The product.
includeProductProperties bool
Determines whether product properties should be included in result.

Returns

IEnumerable<Category>
A collection of categories containing 0 or more items.

GetCategories(Product, string, bool)

Gets the Category objects for each of the Group this belongs.
[Obsolete("Use the overload without languageId instead.")]
public IEnumerable<Category> GetCategories(Product product, string languageId, bool includeProductProperties)

Parameters

product Product
The product.
languageId string
The language ID.
includeProductProperties bool
Determines whether product properties should be included in result.

Returns

IEnumerable<Category>
A collection of categories containing 0 or more items.

GetCategoriesByLanguage(string)

Returns all category objects from database matching the given Language ID.
[Obsolete("Use GetCategories() instead.")]
public IEnumerable<Category> GetCategoriesByLanguage(string languageId)

Parameters

languageId string

Returns

IEnumerable<Category>
A collection of categories containing 0 or more items.

GetCategoriesUsages()

public Dictionary<string, int> GetCategoriesUsages()

Returns

Dictionary<string, int>

GetCategoryById(string)

Returns the Category with the given ID. The default Language is used.
public Category GetCategoryById(string categoryId)

Parameters

categoryId string
The ID of the Category to find.

Returns

Category
A Category or null.

GetCategoryById(string, string)

Returns the Category with the given ID and Language ID.
[Obsolete("Use the overload without languageId instead.")]
public Category GetCategoryById(string categoryId, string languageId)

Parameters

categoryId string
The ID of the Category to find.
languageId string
The LanguageID of the Category to find.

Returns

Category
A Category or null.

GetCategoryLabel(string, string)

[Obsolete("Use GetCategoryById(string categoryId).GetName(string languageId)")]
public string GetCategoryLabel(string categoryId, string languageId)

Parameters

categoryId string
languageId string

Returns

string

GetCategoryUsageCount(string, bool)

public int GetCategoryUsageCount(string categoryId, bool productUsages)

Parameters

categoryId string
productUsages bool

Returns

int

GetCategoryUsageReferences(string, bool, int, int, string, string)

public IEnumerable<CategoryUsage> GetCategoryUsageReferences(string categoryId, bool productUsages, int pageNumber = 1, int pageSize = 100, string orderBy = null, string orderByDirection = null)

Parameters

categoryId string
productUsages bool
pageNumber int
pageSize int
orderBy string
orderByDirection string

Returns

IEnumerable<CategoryUsage>

GetFieldOptionsFromXml(string, string, string)

Converts XML string to the fields options.
public FieldOptionCollection GetFieldOptionsFromXml(string categoryId, string fieldId, string xml)

Parameters

categoryId string
The category id.
fieldId string
The field id.
xml string
The XML string.

Returns

FieldOptionCollection

GetFields()

public Dictionary<string, FieldCollection> GetFields()

Returns

Dictionary<string, FieldCollection>

GetFields(string)

public Dictionary<string, FieldCollection> GetFields(string languageId)

Parameters

languageId string

Returns

Dictionary<string, FieldCollection>

GetFieldsByCategoryId(string)

public FieldCollection GetFieldsByCategoryId(string categoryId)

Parameters

categoryId string

Returns

FieldCollection

GetFieldsByCategoryId(string, string)

[Obsolete("Use GetFieldsByCategoryId(string categoryId) instead.")]
public FieldCollection GetFieldsByCategoryId(string categoryId, string languageId)

Parameters

categoryId string
languageId string

Returns

FieldCollection

GetGroupCategoryFieldValue(Group, Field, bool)

Gets the category field value.
public FieldValueAndInheritanceInformation GetGroupCategoryFieldValue(Group group, Field field, bool allowFallback)

Parameters

group Group
The group information.
field Field
The field.
allowFallback bool
Specifies if fallback values should be used, when the group does not yield a value.

Returns

FieldValueAndInheritanceInformation
category field value

GetProductCategoryFieldValue(Product, Field)

Gets the category field value.
public FieldValueAndInheritanceInformation GetProductCategoryFieldValue(Product product, Field field)

Parameters

product Product
The product information.
field Field
The field.

Returns

FieldValueAndInheritanceInformation
category field value

GetUsageCount(Category)

public int GetUsageCount(Category category)

Parameters

category Category

Returns

int

GetUsageGroupsAsCollection(Category)

public List<string> GetUsageGroupsAsCollection(Category category)

Parameters

category Category

Returns

List<string>

ParseFieldValue(Field, object)

Parses the value based on the FieldType of the Field.
public object ParseFieldValue(Field theField, object value)

Parameters

theField Field
The field.
value object
The value.

Returns

object
The parsed value.

ParseFieldValue(object, int)

Parses the value based on the FieldType of the Field.
public object ParseFieldValue(object value, int type)

Parameters

value object
The value.
type int
The value type.

Returns

object
The parsed value.

SaveCategory(Category)

Saves the Category.
public void SaveCategory(Category theCategory)

Parameters

theCategory Category

SaveField(Field)

Saves this instance.
public void SaveField(Field theField)

Parameters

theField Field

ShowField(Field, Product)

Return a boolean, which indicates whether or not the field should be shown. This is calculated based on the 'HideIfFieldHasNoValue' and the value of the field.
public bool ShowField(Field field, Product product)

Parameters

field Field
product Product
The product we check for

Returns

bool
To top