Table of Contents

Class ProductService

Namespace
Dynamicweb.Ecommerce.Products
Assembly
Dynamicweb.Ecommerce.dll
public class ProductService : ICacheStorage<ProductKey, Product>, ICacheStorage<ProductKey>, ICacheStorage
Inheritance
ProductService
Implements
Inherited Members

Constructors

ProductService()

public ProductService()

Methods

AddGroup(Product, Group)

Adds the group to the products Groups collection. Also creates the ProductGroupRelation in the database if it does not already exist and group.ID is exists.
public void AddGroup(Product product, Group group)

Parameters

product Product
group Group

Examples

class MyPage : System.Web.UI.Page
{
private Product product;
public string AddGroups(GroupCollection gc)
{
foreach(Group group in gc)
{
product.AddGroup(group);
}
}
}

AddRelatedProduct(Product, Product, ProductRelatedGroup)

Adds a related product to this product and saves it to the database.
public void AddRelatedProduct(Product product, Product productToRelate, ProductRelatedGroup relatedProductGroup)

Parameters

product Product
productToRelate Product
relatedProductGroup ProductRelatedGroup

Exceptions

ArgumentException
If this instance is not saved first.
ArgumentException
If the related product is not saved first.
ArgumentException
If the relation group is not saved first.

AddRelatedProduct(string, Product, ProductRelatedGroup)

Adds a related product to this product and saves it to the database.
public void AddRelatedProduct(string productId, Product relatedProduct, ProductRelatedGroup relatedProductGroup)

Parameters

productId string
relatedProduct Product
relatedProductGroup ProductRelatedGroup

Exceptions

ArgumentException
If this instance is not saved first.
ArgumentException
If the related product is not saved first.
ArgumentException
If the relation group is not saved first.

AddVariantGroup(Product, VariantGroup)

Adds the variant group.
public void AddVariantGroup(Product product, VariantGroup variantGroup)

Parameters

product Product
variantGroup VariantGroup
The VariantGroup object.

Examples

class MyPage : System.Web.UI.Page
{
private void AddVariantGrpProdRelated()
{
Product product = new Product();
product = (Product)Session["Ecom.Backend.Product"];

string varGrpID = Context.Current.Request.QueryString["grpArr"];
bool addRelation = false;

Dynamicweb.eCommerce.Variants.VariantGroup variantGrp = Dynamicweb.eCommerce.Variants.VariantGroup.Create(varGrpID);
if (!product.VariantGroups.Contains(variantGrp, true))
{
addRelation = true;
product.AddVariantGroup(variantGrp);
}

if (addRelation)
{
Dynamicweb.eCommerce.Variants.VariantGroupProductRelation vgpr = new Dynamicweb.eCommerce.Variants.VariantGroupProductRelation(product.ID, varGrpID);
try
{
vgpr.ProductID = product.ID;
vgpr.VariantGroupID = varGrpID;
vgpr.Save(product.ID, varGrpID);
}
catch (Exception ex)
{
Nothing
}
}
}
}

AreProductsTheSame(Product, Product)

public bool AreProductsTheSame(Product product1, Product product2)

Parameters

product1 Product
product2 Product

Returns

bool

CalculateVolume(Product)

public double CalculateVolume(Product product)

Parameters

product Product

Returns

double

ChangeWorkflowState(Product, WorkflowState)

public void ChangeWorkflowState(Product product, WorkflowState workflowState)

Parameters

product Product
workflowState WorkflowState

CleanUpProductVersions()

Cleans product versions based on globalsettings
public void CleanUpProductVersions()

Remarks

The settings: "/Globalsettings/Settings/Ecom/PIM/EnableVersionCleanup" indicates whether the clean-up logic will be executed "/Globalsettings/Settings/Ecom/PIM/VersionRetention" indicates how old should be version to be deleted in days "/Globalsettings/Settings/Ecom/PIM/VersionKeepAmount" indicates how many versions should be left no matter what

ClearCache()

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

ClearCache(ProductKey)

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

Parameters

key ProductKey
Key to reset

ClearCache(IEnumerable<ProductKey>)

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

Parameters

keys IEnumerable<ProductKey>
Keys to reset

Clone(Product)

Clones this instance.
public Product Clone(Product product)

Parameters

product Product

Returns

Product

Examples

class MyPage : System.Web.UI.Page
{
private Product product;
public void DoSave()
{
Product product = new Product();
product = product.Clone();
product.ID = string.Empty;
product.VariantID = string.Empty;
product.Save(product.ID, product.VariantID);
}
}

Copy(Product, string, string)

Creates a new instance of a product, and applies a new product id and variant id to it.
public Product Copy(Product productToCopy, string newProductId, string newVariantId)

Parameters

productToCopy Product
The product to copy
newProductId string
The product id of the new instance. If this is null or empty, a new product id will be generated
newVariantId string
The variant id of the new instance

Returns

Product

CurrentBackendUserCanEdit(Product)

Checks if the current backend user has permission to edit a given product.
public bool CurrentBackendUserCanEdit(Product theProduct)

Parameters

theProduct Product
the product in question

Returns

bool
True if the current backend user has permission to edit the given product. False if he doesn't, or if no backend user is logged in

Delete(IEnumerable<Product>)

[Obsolete("Use DeleteProducts method instead.")]
public string Delete(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>

Returns

string

Delete(string, string)

public void Delete(string productId, string productVariantId = null)

Parameters

productId string
productVariantId string

Delete(string, string, string)

Deletes this Product. If this instance is a Variant or a specific language version, then only this instance is deleted. Requires the product to be in the Database or exception is thrown.
public void Delete(string productId, string variantId, string languageId)

Parameters

productId string
variantId string
languageId string

Exceptions

ArgumentException
If Product does not exist in the database.

DeleteAll(IEnumerable<Product>, bool)

Deletes all.
public string DeleteAll(IEnumerable<Product> products, bool doRun)

Parameters

products IEnumerable<Product>
The products.
doRun bool
if set to true execute.

Returns

string
The SQL query

Examples

class MyPage : System.Web.UI.Page
{
public void DoDelete(string SQL)
{
TODO: insert your code here

ProductCollection products = new ProductCollection();
products.Load(SQL);
SQL = Product.DeleteAll(products, false);
Database.ExecuteNonQuery(SQL);
}
}

DeleteAll(IEnumerable<string>, bool)

Deletes all.
public string DeleteAll(IEnumerable<string> ids, bool doRun)

Parameters

ids IEnumerable<string>
The list of IDs.
doRun bool
if set to true execute.

Returns

string
The SQL query

Examples

class MyPage : System.Web.UI.Page
{
public void DoDelete(string SQL)
{
ProductCollection products = new ProductCollection();
products.Load(SQL);
List<string> idList = new List<string>();
foreach (Product product in products)
{
idList.Add(product.ID);
}

SQL = Product.DeleteAll(idList, false);
Database.ExecuteNonQuery(SQL);
}
}

DeleteLanguageSpecificProduct(string, string, string, bool)

Deletes the variant.
public void DeleteLanguageSpecificProduct(string productId, string productVariantId, string productLanguageId, bool forceDelete = false)

Parameters

productId string
DB field name is ProductID.
productVariantId string
DB field name is ProductVariantID.
productLanguageId string
DB field name is ProductLanguageID.
forceDelete bool

Examples

class MyPage : System.Web.UI.Page
{
public void DoDelete(string ProductID, string VariantID, string productLanguageId)
{
TODO: insert your code here

Product.DeleteLanguageSpecificProduct(ProductID, VariantID, productLanguageId);
}
}

DeleteProducts(IEnumerable<Product>)

Deletes the specified products.
public CommandBuilder DeleteProducts(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>
The products.

Returns

CommandBuilder
The SQL query.

DeleteVariants(string, string)

Deletes the specified variant from all language layers.
public void DeleteVariants(string productId, string productVariantId)

Parameters

productId string
DB field name is ProductID.
productVariantId string
DB field name is ProductVariantID.

Examples

class MyPage : System.Web.UI.Page
{
public void DoDelete(string ProductID, string VariantID)
{
TODO: insert your code here

Product.DeleteVariants(ProductID, VariantID);
}
}

DeleteVariantsInVariantOptionGroup(string)

public void DeleteVariantsInVariantOptionGroup(string variantOptionGroupId)

Parameters

variantOptionGroupId string

Fill(ref Product, IDataReader)

Fills the properties from DataReader.
[Obsolete("Don't use")]
public void Fill(ref Product product, IDataReader dataReader)

Parameters

product Product
dataReader IDataReader
DataReader.

Fill(IDataReader)

Fills the properties from DataReader.
[Obsolete("Don't use")]
public void Fill(IDataReader dataReader)

Parameters

dataReader IDataReader
DataReader.

GetActiveProducts(string, bool)

Gets the active products.
public IEnumerable<Product> GetActiveProducts(string productLanguageId, bool useAssortments)

Parameters

productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string productLanguageId)
{
ProductCollection dwProds = Product.GetActiveProducts(productLanguageId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetAllProducts(string, bool)

Gets all products.
[Obsolete("Do not use", false)]
public IEnumerable<Product> GetAllProducts(string productLanguageId, bool useAssortments)

Parameters

productLanguageId string
The language ID to use.
useAssortments bool

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getProducts()
{
ProductCollection dwProds = Product.getAllProducts();
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetAllProductsByShopId(string, bool)

Gets all products from shop. No language filter is applied meaning all language version of all products in the shop are returned.
public IEnumerable<Product> GetAllProductsByShopId(string shopId, bool useAssortments)

Parameters

shopId string
DB field name is ShopGroupShopID.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string shopID)
{
ProductCollection dwProds = Product.GetAllProductsByShopID(shopID);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetAllProductsWithoutVariants(bool, string, bool)

Gets all products without variants.
public IEnumerable<Product> GetAllProductsWithoutVariants(bool doRefactoring, string productLanguageId, bool useAssortments)

Parameters

doRefactoring bool
if set to true; - do refactoring the product collection.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getProducts(string productLanguageId)
{
ProductCollection dwProds = Product.GetAllProductsWithoutVariants(true, productLanguageId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetAllProductVersions(string)

Gets all versions for the product include versions for any variants and any versions.
public IEnumerable<VersionData> GetAllProductVersions(string productId)

Parameters

productId string
The product ID.

Returns

IEnumerable<VersionData>
The collection of the VersionData.

GetByAutoIDs(IList<long>)

public IEnumerable<Product> GetByAutoIDs(IList<long> autoIDs)

Parameters

autoIDs IList<long>

Returns

IEnumerable<Product>

GetByPage(string, bool, string, int, int, bool, string, string)

[Obsolete]
public IEnumerable<Product> GetByPage(string searchText, bool useBackCatalog, string showProducts, int pageNumber, int pageSize, bool searchAllFields, string orderBy, string assortmentId)

Parameters

searchText string
useBackCatalog bool
showProducts string
pageNumber int
pageSize int
searchAllFields bool
orderBy string
assortmentId string

Returns

IEnumerable<Product>

GetByPage(string, bool, string, int, int, bool, string, string, IEnumerable<string>)

[Obsolete("Use overload with shoptype parameter")]
public IEnumerable<Product> GetByPage(string searchText, bool useBackCatalog, string showProducts, int pageNumber, int pageSize, bool searchAllFields, string orderBy, string assortmentId, IEnumerable<string> shopIds)

Parameters

searchText string
useBackCatalog bool
showProducts string
pageNumber int
pageSize int
searchAllFields bool
orderBy string
assortmentId string
shopIds IEnumerable<string>

Returns

IEnumerable<Product>

GetByPage(string, bool, string, int, int, bool, string, string, IEnumerable<string>, ShopType?)

public IEnumerable<Product> GetByPage(string searchText, bool useBackCatalog, string showProducts, int pageNumber, int pageSize, bool searchAllFields, string orderBy, string assortmentId, IEnumerable<string> shopIds, ShopType? shopType)

Parameters

searchText string
useBackCatalog bool
showProducts string
pageNumber int
pageSize int
searchAllFields bool
orderBy string
assortmentId string
shopIds IEnumerable<string>
shopType ShopType?

Returns

IEnumerable<Product>

GetByProductIDs(string[], bool, string, bool, bool)

public IEnumerable<Product> GetByProductIDs(string[] productIds, bool doRefactoring, string productLanguageId, bool bulkFill, bool useAssortments)

Parameters

productIds string[]
doRefactoring bool
productLanguageId string
bulkFill bool
useAssortments bool

Returns

IEnumerable<Product>

GetByProductIDsAndVariantIDs(List<Tuple<string, string>>, IEnumerable<string>, bool, bool)

public IEnumerable<Product> GetByProductIDsAndVariantIDs(List<Tuple<string, string>> idCombinations, IEnumerable<string> productLanguageIds, bool doRefactoring, bool useAssortments)

Parameters

idCombinations List<Tuple<string, string>>
productLanguageIds IEnumerable<string>
doRefactoring bool
useAssortments bool

Returns

IEnumerable<Product>

GetByProductIDsAndVariantIDs(List<Tuple<string, string>>, string, bool, bool)

public IEnumerable<Product> GetByProductIDsAndVariantIDs(List<Tuple<string, string>> idCombinations, string productLanguageId, bool doRefactoring, bool useAssortments)

Parameters

idCombinations List<Tuple<string, string>>
productLanguageId string
doRefactoring bool
useAssortments bool

Returns

IEnumerable<Product>

GetBySearchTerm(string, string, string)

[Obsolete]
public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID)

Parameters

searchValue string
groupID string
variantID string

Returns

IEnumerable<Product>

GetBySearchTerm(string, string, string, IEnumerable<ShopType>)

public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID, IEnumerable<ShopType> shopTypes)

Parameters

searchValue string
groupID string
variantID string
shopTypes IEnumerable<ShopType>

Returns

IEnumerable<Product>

GetBySearchTerm(string, string, string, IEnumerable<ShopType>, bool)

public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID, IEnumerable<ShopType> shopTypes, bool searchInAllFields)

Parameters

searchValue string
groupID string
variantID string
shopTypes IEnumerable<ShopType>
searchInAllFields bool

Returns

IEnumerable<Product>

GetCommandBuilderConditionPartForIds(IEnumerable<Product>)

Gets the condition part of a SQL statement.
public CommandBuilder GetCommandBuilderConditionPartForIds(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>
The products.

Returns

CommandBuilder
The condition part of a SQL statement based on the given products

GetCommandBuilderConditionPartForIds(IEnumerable<string>)

Gets the condition part of a SQL statement.
public CommandBuilder GetCommandBuilderConditionPartForIds(IEnumerable<string> ids)

Parameters

ids IEnumerable<string>
The ID or IDs. Multiple IDs must be separated by ', ' or ','.

Returns

CommandBuilder
The condition part of a SQL statement based on the given ID or IDs

Examples

class MyPage : System.Web.UI.Page
{
public string DeleteAll(GroupCollection groups, bool run)
{
var grps = groups.Select(Function(g) g.Id);
System.Text.StringBuilder SQL = new System.Text.StringBuilder();

01) Delete group releations
SQL.Append("DELETE FROM EcomGroupRelations WHERE GroupRelationsGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
02) Delete group to shop releations
SQL.Append("DELETE FROM EcomShopGroupRelation WHERE ShopGroupGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
03) Delete the items (BOM) groups from products
SQL.Append("DELETE FROM EcomProductItems WHERE ProductItemBomGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
04) Delete the groups
SQL.Append("DELETE FROM EcomGroups WHERE GroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");

if (run)
{
Database.ExecuteNonQuery(SQL.ToString());

Sending out notifications
Dynamicweb.Extensibility.NotificationManager.Notify(Dynamicweb.Ecommerce.Notifications.eCommerce.Group.Deleted, new Dynamicweb.Ecommerce.Notifications.eCommerce.Group.GroupModifiedEventArgs(groups));
}
return SQL.ToString();
}
}

GetCommaSeparatedProductIDs(IEnumerable<Product>)

Returns list of IDs.
[Obsolete("Use GetProductsIds instead")]
public string GetCommaSeparatedProductIDs(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>
The products.

Returns

string

Examples

class MyPage : System.Web.UI.Page
{
public string Delete(ProductCollection products, bool run)
{
string SQL = "DELETE FROM EcomDetails WHERE DetailProductID " + Product.GetSqlConditionPartForIDs(Product.GetCommaSeparatedProductIDs(products)) + "; ";
if (run)
{
Database.ExecuteNonQuery(SQL);
}
return SQL;
}
}

Exceptions

ArgumentNullException
If given ProductCollection is null.

GetCompletenessStatus(Product, Shop, IEnumerable<Group>)

public int GetCompletenessStatus(Product masterProduct, Shop shop, IEnumerable<Group> groups)

Parameters

masterProduct Product
shop Shop
groups IEnumerable<Group>

Returns

int

GetCountOfAllProductsWithoutVariants()

public int GetCountOfAllProductsWithoutVariants()

Returns

int

GetFieldValue(Product, ProductField)

Gets the product field value.
public ApplicationResponse<object> GetFieldValue(Product product, ProductField field)

Parameters

product Product
field ProductField

Returns

ApplicationResponse<object>

GetIdUrlEncoded(string)

Gets the ID URL encoded.
[Obsolete("System.Net.WebUtility.UrlEncode for encoding")]
public string GetIdUrlEncoded(string id)

Parameters

id string

Returns

string

GetLastActiveProducts(int, string, bool)

Gets the last active products.
public IEnumerable<Product> GetLastActiveProducts(int count, string productLanguageId, bool useAssortments)

Parameters

count int
Select top from selected items.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string productLanguageId)
{
ProductCollection dwProds = Product.GetLastActiveProducts(10, productLanguageId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetLastActiveProducts(int, string[], string, bool)

Gets the last active products. Context.LanguageID is used.
public IEnumerable<Product> GetLastActiveProducts(int count, string[] groupIds, string productLanguageId, bool useAssortments)

Parameters

count int
Select top from selected items.
groupIds string[]
The array of group IDs.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string[] groupIds, string productLanguageId)
{
ProductCollection dwProds = Product.GetLastActiveProducts(10, groupIds, productLanguageId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetPagedProductsByVariantGroup(VariantGroup, int, int)

Gets the products portion limited by page size.
public IEnumerable<Product> GetPagedProductsByVariantGroup(VariantGroup variantGroup, int pageNumber, int pageSize)

Parameters

variantGroup VariantGroup
The VariantGroup object.
pageNumber int
pageSize int

Returns

IEnumerable<Product>

GetProductById(string, string, bool)

Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, bool useDefaultLanguage)

Parameters

productId string
The product ID.
productVariantId string
The variant ID.
useDefaultLanguage bool
if set to true [use default language].

Returns

Product

GetProductById(string, string, string)

Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId)

Parameters

productId string
The product ID.
productVariantId string
The variant ID.
productLanguageId string
The language ID.

Returns

Product

Remarks

When specified product with variant id and language not equal Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageID

GetProductById(string, string, string, User)

Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, User user)

Parameters

productId string
The product ID.
productVariantId string
The variant ID.
productLanguageId string
The language ID.
user User
User that needs access to the product

Returns

Product

Remarks

When specified product with variant id and language not equal Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageID

GetProductById(string, string, string, bool)

Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, bool useAssortments)

Parameters

productId string
The product ID.
productVariantId string
The variant ID.
productLanguageId string
The language ID.
useAssortments bool
If set to true use assortments.

Returns

Product

Remarks

When specified product with variant id and language not equal Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageID

GetProductById(string, string, string, int)

Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, int userId)

Parameters

productId string
The product ID.
productVariantId string
The variant ID.
productLanguageId string
The language ID.
userId int

Returns

Product

Remarks

When specified product with variant id and language not equal Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageID

GetProductByKey(ProductKey)

public Product GetProductByKey(ProductKey productKey)

Parameters

productKey ProductKey

Returns

Product

GetProductByNumber(string, bool)

Gets the product by number.
[Obsolete("Please use an overload with the languageId parameter")]
public Product GetProductByNumber(string productNumber, bool useDefaultLanguage)

Parameters

productNumber string
Product number.
useDefaultLanguage bool
Value indicating whether to use default language.

Returns

Product
Product with the given number or null (Nothing in Visual Basic) if product with the given number cannot be found.

GetProductByNumber(string, string)

Gets the product by number.
public Product GetProductByNumber(string productNumber, string productLanguageId)

Parameters

productNumber string
Product number.
productLanguageId string
The language ID.

Returns

Product
Product with the given number or null (Nothing in Visual Basic) if product with the given number cannot be found.

GetProductCountByVariantGroup(VariantGroup)

public int GetProductCountByVariantGroup(VariantGroup variantGroup)

Parameters

variantGroup VariantGroup

Returns

int

GetProductDataSet()

Gets an empty DataSet that matches the database schema.
[Obsolete("Should exist in repository")]
public DataSet GetProductDataSet()

Returns

DataSet

GetProductDataSet(string)

Gets a DataSet with the Products and Variants that match the given product ID.
[Obsolete("Should only exist in repository")]
public DataSet GetProductDataSet(string productId)

Parameters

productId string
The product ID.

Returns

DataSet

GetProductFieldValue(Product, string)

Gets the product field value.
public object GetProductFieldValue(Product product, string productFieldSystemName)

Parameters

product Product
productFieldSystemName string
SystemName of the ProductField.

Returns

object

Exceptions

ArgumentException
If not ProductField or ProductFieldValue exist based on the given SystemName.

GetProductsAndVariantsByProduct(Product)

Gets the all products and variants with the same product ID and language ID as the given product.
public IEnumerable<Product> GetProductsAndVariantsByProduct(Product product)

Parameters

product Product
The product.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getActiveProducts(Product product)
{
ProductCollection dwProds = Product.GetProductsAndVariantsByProduct(product);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroup(Group, string, bool)

Gets the products from group.
public IEnumerable<Product> GetProductsByGroup(Group group, string productLanguageId, bool useAssortments)

Parameters

group Group
The group.
productLanguageId string
The language ID.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void DeleteProducts(GroupCollection groups)
{
if (groups.Count > 0)
{
Delete products from groups
ProductCollection productIds = Product.GetProductsByGroup(groups);
Dynamicweb.eCommerce.Products.ProductDeleting.Run(productIds, groups);
}
}
}

GetProductsByGroupId(string, bool, bool, string, bool, bool)

Gets the products.
public IEnumerable<Product> GetProductsByGroupId(string groupId, bool useOrderBy, bool includeVariants, string productLanguageId, bool doRefactoring, bool useAssortments)

Parameters

groupId string
The group ID.
useOrderBy bool
if set to true the returned collection of product is sorted by the user defined sort order. If set to false the products are returned unsorted.
includeVariants bool
if set to true gets all variants.
productLanguageId string
The language ID.
doRefactoring bool
if set to true remove unused products.
useAssortments bool
If set to true assortments are used to filter collection.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getOrderProducts(string groupID, string productLanguageId, bool doRefactoring)
{
ProductCollection dwProds = Product.GetProductsByGroupID(groupID, true, true, productLanguageId, doRefactoring);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupId(string, bool, string, bool)

Gets the product collection based on Group ID.
public IEnumerable<Product> GetProductsByGroupId(string groupId, bool onlyActive, string productLanguageId, bool useAssortments)

Parameters

groupId string
The group ID.
onlyActive bool
if set to true removes not active items from collection.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter the collection.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string groupID)
{
ProductCollection dwProds = Product.GetProductsByGroupID(groupID, true);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupId(string, int, bool, string, bool)

Gets the products. Context.LanguageID is used.
public IEnumerable<Product> GetProductsByGroupId(string groupId, int top, bool doRefactoring, string productLanguageId, bool useAssortments)

Parameters

groupId string
The group ID.
top int
doRefactoring bool
if set to true removes not used items.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are use to filter the collection.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string groupID, int top)
{
ProductCollection dwProds = Product.GetProductsByGroupID(groupID, top, true);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupIdAndSearchValue(string, string, string, string)

Gets the products. Context.LanguageID is used.
public IEnumerable<Product> GetProductsByGroupIdAndSearchValue(string groupId, string topValue, string searchValue, string productVariantId)

Parameters

groupId string
The group ID.
topValue string
The top value.
searchValue string
The search value.
productVariantId string
The variant ID.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string groupID)
{
string searchKeyWord = Context.Current.Request["searchField"];
ProductCollection dwProds = Product.GetProductsByGroupIDAndSearchValue(groupID, "100", searchKeyWord, "");
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupIdAndSearchValue(string, string, string, string, bool)

Gets the products. Context.LanguageID is used.
public IEnumerable<Product> GetProductsByGroupIdAndSearchValue(string groupId, string topValue, string searchValue, string productVariantId, bool isFrontend)

Parameters

groupId string
The group ID.
topValue string
The top value, i.e. the number of products to get.
searchValue string
The search value.
productVariantId string
The variant ID.
isFrontend bool
if set to true removes not used items.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getActiveProducts(string groupID)
{
string searchKeyWord = Context.Current.Request["searchField"];
ProductCollection dwProds = Product.GetProductsByGroupIDAndSearchValue(groupID, "100", searchKeyWord, "", true);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupIdAndSearchValue(string, string, string, string, bool, string)

Gets the products.
public IEnumerable<Product> GetProductsByGroupIdAndSearchValue(string groupId, string topValue, string searchValue, string productVariantId, bool isFrontend, string productLanguageId)

Parameters

groupId string
The group ID.
topValue string
The top value, i.e. the number of products to get.
searchValue string
The search value.
productVariantId string
The variant ID.
isFrontend bool
if set to true removes not used items.
productLanguageId string
The language ID to use.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getActiveProducts(string groupID)
{
string searchKeyWord = Context.Current.Request["searchField"];
ProductCollection dwProds = Product.GetProductsByGroupIDAndSearchValue(groupID, "100", searchKeyWord, "", true);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroupIdAndSearchValue(string, string, string, string, bool, string, bool)

Gets the products.
public IEnumerable<Product> GetProductsByGroupIdAndSearchValue(string groupId, string topValue, string searchValue, string productVariantId, bool isFrontend, string productLanguageId, bool useAssortments)

Parameters

groupId string
The group ID.
topValue string
The top value, i.e. the number of products to get.
searchValue string
The search value.
productVariantId string
The variant ID.
isFrontend bool
if set to true removes not used items.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter collection.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getActiveProducts(string groupID)
{
string searchKeyWord = Context.Current.Request["searchField"];
ProductCollection dwProds = Product.GetProductsByGroupIDAndSearchValue(groupID, "100", searchKeyWord, "", true);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByGroups(GroupCollection, string, bool, bool)

Gets the products from groups.
public IEnumerable<Product> GetProductsByGroups(GroupCollection groups, string productLanguageId, bool isFrontEnd, bool useAssortments)

Parameters

groups GroupCollection
The groups.
productLanguageId string
The language ID.
isFrontEnd bool
if set to true removes not used items.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void DeleteProducts(GroupCollection groups)
{
if (groups.Count > 0)
{
Delete products from groups
ProductCollection productIds = Product.GetProductsByGroups(groups, false);
Dynamicweb.eCommerce.Products.ProductDeleting.Run(productIds, groups);
}
}
}

GetProductsByKeys(IEnumerable<ProductKey>)

public IEnumerable<Product> GetProductsByKeys(IEnumerable<ProductKey> productKeys)

Parameters

productKeys IEnumerable<ProductKey>

Returns

IEnumerable<Product>

GetProductsByNumber(string, string)

Gets a list of products by number.
public IEnumerable<Product> GetProductsByNumber(string productNumber, string productLanguageId)

Parameters

productNumber string
Product number.
productLanguageId string
The language ID.

Returns

IEnumerable<Product>
Products with the given number or null if products with the given number cannot be found.

GetProductsByProductAndVariantId(Product, string)

Gets the products.
public IEnumerable<Product> GetProductsByProductAndVariantId(Product product, string productVariantId)

Parameters

product Product
The product.
productVariantId string
The variant ID.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
private Dynamicweb.eCommerce.Products.Product product;
public void getActiveProducts(string variantId)
{
ProductCollection dwProds = Product.GetProductsByProductAndVariantID(product, variantId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsByProductAndVariantId(Product, string, bool)

Gets the products.
public IEnumerable<Product> GetProductsByProductAndVariantId(Product product, string productVariantId, bool useAssortments)

Parameters

product Product
The product.
productVariantId string
The variant ID.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

GetProductsByShopId(string, string, bool)

Gets products from shop.
public IEnumerable<Product> GetProductsByShopId(string shopId, string productLanguageId, bool useAssortments)

Parameters

shopId string
DB field name is ShopGroupShopID.
productLanguageId string
The language ID to use.
useAssortments bool
If set to true assortments are used to filter products.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public static void getActiveProducts(string shopID, string productLanguageId)
{
ProductCollection dwProds = Product.GetProductsByShopID(shopID, productLanguageId);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsBySql(bool, string)

Gets the ProductCollection object.
[Obsolete("Don't use this")]
public IEnumerable<Product> GetProductsBySql(bool useAssortments, string query)

Parameters

useAssortments bool
if set to true assortments are used to filter the product collection.
query string
The SQL query.

Returns

IEnumerable<Product>

GetProductsBySql(string)

Gets the ProductCollection object.
[Obsolete("Don't use")]
public IEnumerable<Product> GetProductsBySql(string query)

Parameters

query string
The SQL query.

Returns

IEnumerable<Product>

GetProductsBySql(string, bool)

Gets the ProductCollection object.
[Obsolete("Don't use")]
public IEnumerable<Product> GetProductsBySql(string query, bool doRefactoring)

Parameters

query string
The SQL query.
doRefactoring bool
if set to true removes products that are not in stock, do not have a price (0), or is not active, or is not in a current assortments.

Returns

IEnumerable<Product>

GetProductsBySql(string, bool, bool)

Gets the products by SQL.
[Obsolete("Don't use this")]
public IEnumerable<Product> GetProductsBySql(string query, bool doRefactoring, bool bulkFill)

Parameters

query string
The SQL.
doRefactoring bool
if set to true removes products that are not in stock, do not have a price (0), or is not active, or is not in a current assortments.
bulkFill bool
if set to true [bulk fill].

Returns

IEnumerable<Product>

GetProductsByVariantGroup(VariantGroup)

Gets the products.
public IEnumerable<Product> GetProductsByVariantGroup(VariantGroup variantGroup)

Parameters

variantGroup VariantGroup
The VariantGroup object.

Returns

IEnumerable<Product>

Examples

class MyPage : System.Web.UI.Page
{
public void getActiveProducts(Dynamicweb.eCommerce.Variants.VariantGroup vgpr)
{
ProductCollection dwProds = Product.GetProductsByVariantGroup(vgrp);
foreach (Product dwProd in dwProds)
{
TODO: insert your code here
}
}
}

GetProductsCountByGroupId(string, bool, string, string, bool, bool)

Gets the products count.
public int GetProductsCountByGroupId(string groupId, bool countOnlyActive, string searchValue, string productLanguageId, bool includeVariants, bool doRefactoring)

Parameters

groupId string
The group ID.
countOnlyActive bool
if set to true count only active products.
searchValue string
The search value.
productLanguageId string
The language ID.
includeVariants bool
if set to true gets all variants.
doRefactoring bool
if set to true remove unused products.

Returns

int

GetProductsCountByGroupId(string, string, string, bool, bool)

Gets the products count.
public int GetProductsCountByGroupId(string groupId, string searchValue, string productLanguageId, bool includeVariants, bool doRefactoring)

Parameters

groupId string
The group ID.
searchValue string
The search value.
productLanguageId string
The language ID.
includeVariants bool
if set to true gets all variants.
doRefactoring bool
if set to true remove unused products.

Returns

int

GetProductsIds(IEnumerable<Product>)

Returns list of IDs.
public IEnumerable<string> GetProductsIds(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>
The products.

Returns

IEnumerable<string>

Examples

class MyPage : System.Web.UI.Page
{
public string Delete(ProductCollection products, bool run)
{
string SQL = "DELETE FROM EcomDetails WHERE DetailProductID " + Product.GetSqlConditionPartForIDs(Product.GetProductsIds(products)) + "; ";
if (run)
{
Database.ExecuteNonQuery(SQL);
}
return SQL;
}
}

Exceptions

ArgumentNullException
If given ProductCollection is null.

GetPropertyValue(Product, string)

Gets the property value.
public object GetPropertyValue(Product product, string propertyName)

Parameters

product Product
propertyName string
Name of the property.

Returns

object

GetRelatedCountFrontend(Product)

Gets the RelatedProducts counting.
[Obsolete("Use overload with currency, country, stocklocation, user")]
public int GetRelatedCountFrontend(Product product)

Parameters

product Product

Returns

int

GetRelatedCountFrontend(Product, Currency, Country, StockLocation, User)

public int GetRelatedCountFrontend(Product product, Currency currency, Country country, StockLocation stockLocation, User user)

Parameters

product Product
currency Currency
country Country
stockLocation StockLocation
user User

Returns

int

GetRelatedProducts(Product)

Gets the related products. Related products are used to suggest a customer to buy complementary products to the products they want to buy, e.group. a shirt and a tie. Administrator can create relations in Management Center -> eCommerce settings -> Product catalog -> Related products.
[Obsolete("Use Services.ProductRelated.GetRelations instead")]
public IEnumerable<ProductRelated> GetRelatedProducts(Product product)

Parameters

product Product

Returns

IEnumerable<ProductRelated>

Examples

class MyPage : System.Web.UI.Page
{
private Product product;
private Product productNew;
private void SavePrices()
{
foreach (Dynamicweb.eCommerce.Products.ProductRelated pr in product.RelatedProducts)
{
pr.Save(productNew.ID, pr.ProdRelID);
}
}
}

GetSearchResultCount(string, bool, string, bool, bool, bool, string)

[Obsolete]
public int GetSearchResultCount(string searchText, bool useBackCatalog, string showProducts, bool useVariants, bool searchInAllFields, bool onlyActiveProducts, string assortmentId)

Parameters

searchText string
useBackCatalog bool
showProducts string
useVariants bool
searchInAllFields bool
onlyActiveProducts bool
assortmentId string

Returns

int

GetSearchResultCount(string, bool, string, bool, bool, bool, string, IEnumerable<string>)

[Obsolete("Use overload with shoptype parameter")]
public int GetSearchResultCount(string searchText, bool useBackCatalog, string showProducts, bool useVariants, bool searchInAllFields, bool onlyActiveProducts, string assortmentId, IEnumerable<string> shopIds)

Parameters

searchText string
useBackCatalog bool
showProducts string
useVariants bool
searchInAllFields bool
onlyActiveProducts bool
assortmentId string
shopIds IEnumerable<string>

Returns

int

GetSearchResultCount(string, bool, string, bool, bool, bool, string, IEnumerable<string>, ShopType?)

public int GetSearchResultCount(string searchText, bool useBackCatalog, string showProducts, bool useVariants, bool searchInAllFields, bool onlyActiveProducts, string assortmentId, IEnumerable<string> shopIds, ShopType? shopType)

Parameters

searchText string
useBackCatalog bool
showProducts string
useVariants bool
searchInAllFields bool
onlyActiveProducts bool
assortmentId string
shopIds IEnumerable<string>
shopType ShopType?

Returns

int

GetSqlConditionPartForIDs(IEnumerable<Product>)

[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>

Returns

string

GetSqlConditionPartForIDs(IEnumerable<string>)

[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(IEnumerable<string> ids)

Parameters

ids IEnumerable<string>

Returns

string

GetSqlConditionPartForIDs(string)

Gets the condition part of a SQL statement.
[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(string idList)

Parameters

idList string
The ID or IDs. Multiple IDs must be separated by ', ' or ','.

Returns

string
The condition part of a SQL statement based on the given ID or IDs

Examples

class MyPage : System.Web.UI.Page
{
public string DeleteAll(GroupCollection groups, bool run)
{
string grps = Group.WhereClauseBuilder(groups);
System.Text.StringBuilder SQL = new System.Text.StringBuilder();

01) Delete group releations
SQL.Append("DELETE FROM EcomGroupRelations WHERE GroupRelationsGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
02) Delete group to shop releations
SQL.Append("DELETE FROM EcomShopGroupRelation WHERE ShopGroupGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
03) Delete the items (BOM) groups from products
SQL.Append("DELETE FROM EcomProductItems WHERE ProductItemBomGroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");
04) Delete the groups
SQL.Append("DELETE FROM EcomGroups WHERE GroupID " + Product.GetSqlConditionPartForIDs(grps) + "; ");

if (run)
{
Database.ExecuteNonQuery(SQL.ToString());

Sending out notifications
Dynamicweb.Extensibility.NotificationManager.Notify(Dynamicweb.Ecommerce.Notifications.eCommerce.Group.Deleted, new Dynamicweb.Ecommerce.Notifications.eCommerce.Group.GroupModifiedEventArgs(groups));
}
return SQL.ToString();
}
}

GetStockStatus(Product)

Gets the stock status.
public StockStatus GetStockStatus(Product product)

Parameters

product Product

Returns

StockStatus

GetStockStatus(Product, StockLocation)

Gets the stock status.
public StockStatus GetStockStatus(Product product, StockLocation stockLocation)

Parameters

product Product
stockLocation StockLocation

Returns

StockStatus

GetStockStatus(Product, StockLocation, string)

Gets the stock status.
public StockStatus GetStockStatus(Product product, StockLocation stockLocation, string unitId)

Parameters

product Product
stockLocation StockLocation
unitId string

Returns

StockStatus

GetStockStatus(Product, double)

Gets the stock status.
public StockStatus GetStockStatus(Product product, double unitStock)

Parameters

product Product
unitStock double

Returns

StockStatus

GetStockStatus(Product, string)

[Obsolete("Use GetStockStatus(Product) instead.")]
public StockStatus GetStockStatus(Product product, string productLanguageId)

Parameters

product Product
productLanguageId string

Returns

StockStatus

GetVersionProduct(VersionData)

Gets product which stored in versionData.
public Product GetVersionProduct(VersionData version)

Parameters

version VersionData
The version.

Returns

Product
The draft product.

IsActive(Product)

Gets the value that indicates if the product is active or not and if the period of the product is active or not.
public bool IsActive(Product product)

Parameters

product Product

Returns

bool

Remarks

Checks if the product is active and if the period of product is active

IsVariantMaster(Product)

Gets the value that indicates if the variant is a master.
public bool IsVariantMaster(Product product)

Parameters

product Product

Returns

bool

Language(string)

Gets the product language. To change the language of this Product use the LanguageID property.
[Obsolete("Use Services.Languages.GetLanguage instead.")]
public Language Language(string languageId)

Parameters

languageId string

Returns

Language

MakeFullCopyToGroup(Product, string)

Makes a clone of the product and all its relations (except group relations) and saves it in the DB.
public void MakeFullCopyToGroup(Product product, string groupId)

Parameters

product Product
The product.
groupId string
The group ID.

MakeFullCopyToGroup(string, string)

Makes a clone of the product and all its relations (except group relations) and saves it in the DB.
public void MakeFullCopyToGroup(string productId, string groupId)

Parameters

productId string
The product ID.
groupId string
The group ID.

Examples

class MyPage : System.Web.UI.Page
{
public void CopyProducts(ProductCollection products)
{
string groupID = Dynamicweb.Context.Current.Request("ToGroupID");

foreach (Product product in products)
{
Product.MakeFullCopyToGroup(product.ID, groupID);
}
}
}

MakeFullCopyToGroupWithLanguage(Product, string, string, string)

Makes a clone of the product and all its relations (except group relations) for specified languages and saves it in the DB.
[Obsolete("Use overload with productId parameter")]
public string MakeFullCopyToGroupWithLanguage(Product product, string groupId, string productLanguageId, string newProductId)

Parameters

product Product
The product.
groupId string
The group ID.
productLanguageId string
The language ID.
newProductId string
The product ID.

Returns

string
The new Product ID.

MakeFullCopyToGroupWithLanguage(string, string, string, string)

Makes a clone of the product and all its relations (except group relations) for specified languages and saves it in the DB.
public string MakeFullCopyToGroupWithLanguage(string productId, string groupId, string productLanguageId, string newProductId)

Parameters

productId string
The product ID.
groupId string
The group ID.
productLanguageId string
The language ID.
newProductId string
The new Product ID.

Returns

string
The new Product ID.

ProductVariantExists(Product, string)

If variant exists return true.
public bool ProductVariantExists(Product product, string productVariandId)

Parameters

product Product
The product.
productVariandId string
The variant ID.

Returns

bool

Examples

class MyPage : System.Web.UI.Page
{
private void UpdateStock(Dynamicweb.eCommerce.Orders.Order order)
{
foreach (Dynamicweb.eCommerce.Orders.OrderLine orderLine in order.OrderLines)
{
if (Product.ProductVariantExists(orderLine.Product, orderLine.ProductVariantID))
{
TODO: insert your code here
}
}
}
}

ReFactorProductList(ICollection<Product>, Currency, Country, StockLocation, User, bool)

Removes not used items from product list.
public void ReFactorProductList(ICollection<Product> products, Currency currency, Country country, StockLocation stockLocation, User user, bool useAssortments)

Parameters

products ICollection<Product>
currency Currency
country Country
stockLocation StockLocation
user User
useAssortments bool
If set to true then assortments are used to re-factor the product collection.

ReFactorProductList(ICollection<Product>, bool)

Removes not used items from product list.
public void ReFactorProductList(ICollection<Product> products, bool useAssortments)

Parameters

products ICollection<Product>
useAssortments bool
If set to true then assortments are used to re-factor the product collection.

RemoveGroup(Product, Group)

Removes the group from the products Groups collection. Also deletes the ProductGroupRelation from the database if group.ID exists.
public void RemoveGroup(Product product, Group group)

Parameters

product Product
group Group

Examples

class MyPage : System.Web.UI.Page
{
private Product product;
public string RemoveGroups(GroupCollection gc)
{
foreach(Group group in gc)
{
product.RemoveGroup(group);
}
}
}

RemoveItem(Product, string)

Removes the item.
public void RemoveItem(Product product, string itemId)

Parameters

product Product
itemId string
The item ID.

Examples

class MyPage : System.Web.UI.Page
{
private void DelProductItem()
{
Product product = new Product();
product = (Product)Session["Ecom.Backend.Product"];

string itemID = Context.Current.Request.QueryString["itemID"];

product.RemoveItem(itemID);
ProductItem pi = new ProductItem();
pi.Delete(itemID, product.ID);
}
}

RemoveVariantGroup(Product, VariantGroup)

Removes the variant group by object reference.
public void RemoveVariantGroup(Product product, VariantGroup variantGroup)

Parameters

product Product
variantGroup VariantGroup
The VariantGroup object.

Examples

class MyPage : System.Web.UI.Page
{
private void DelVariantGrpProdRelated()
{
Product product = new Product();
product = (Product)Session["Ecom.Backend.Product"];

string varGrpID = Context.Current.Request.QueryString["grpArr"];

Dynamicweb.eCommerce.Variants.VariantGroup variantGrp = Dynamicweb.eCommerce.Variants.VariantGroup.Create(varGrpID);
product.RemoveVariantGroup(variantGrp);

Dynamicweb.eCommerce.Variants.VariantGroupProductRelation vgpr = new Dynamicweb.eCommerce.Variants.VariantGroupProductRelation();
vgpr.Delete(product.ID, varGrpID);

Dynamicweb.eCommerce.Variants.VariantCombination vopr = new Dynamicweb.eCommerce.Variants.VariantCombination();
vopr.Delete(product.ID);

product.VariantGroups = null;
product.VariantCombinations = null;
}
}

RemoveVariantGroupLoop(Product, VariantGroup)

Removes the variant group by ID, LanguageID, Label and Name.
public void RemoveVariantGroupLoop(Product product, VariantGroup variantGroup)

Parameters

product Product
variantGroup VariantGroup
The VariantGroup object.

Examples

class MyPage : System.Web.UI.Page
{
private void DeleteVariantGroupProductRelated()
{
Product product = (Product)Session["Ecom.Backend.Product"];

string variantGroupID = Context.Current.Request.QueryString["grpArr"];

Dynamicweb.eCommerce.Variants.VariantGroup variantGroup = Dynamicweb.eCommerce.Variants.VariantGroup.Create(variantGroupID);
product.RemoveVariantGroupLoop(variantGroup);

Dynamicweb.eCommerce.Variants.VariantGroupProductRelation variantGroupProductRelation = new Dynamicweb.eCommerce.Variants.VariantGroupProductRelation();
variantGroupProductRelation.Delete(product.ID, variantGroupID);

Dynamicweb.eCommerce.Variants.VariantCombination variantCombination = new Dynamicweb.eCommerce.Variants.VariantCombination();
variantCombination.Delete(product.ID);

product.VariantGroups = null;
product.VariantCombinations = null;
}
}

Save(Product)

Saves this instance.
public void Save(Product product)

Parameters

product Product

Save(Product, bool)

Saves this instance.
public void Save(Product product, bool skipExtendedSave)

Parameters

product Product
skipExtendedSave bool
If true; Extended Save of the Product is skipped. Default is false.

Save(Product, string, string)

Saves this instance.
public void Save(Product product, string productId, string productVariantId)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.

Save(Product, string, string, bool)

Saves this instance.
public void Save(Product product, string productId, string productVariantId, bool skipExtendedSave)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
skipExtendedSave bool
If true; Extended Save of the Product is skipped. Default is false.

Save(Product, string, string, string)

Saves this instance. See Save() for example.
public void Save(Product product, string productId, string productVariantId, string productLanguageId)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
productLanguageId string
The product language ID.

Save(Product, string, string, string, bool)

Saves this instance.
public void Save(Product product, string productId, string productVariantId, string productLanguageId, bool skipExtendedSave)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
productLanguageId string
The product language ID.
skipExtendedSave bool
If true; Extended Save of the Product is skipped. Default is false.

SaveAndConfirm(Product, string, string)

Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId)

Parameters

product Product
productId string
DB field name is ProductID.
productVariantId string
DB field name is ProductVariantID.

Returns

bool

SaveAndConfirm(Product, string, string, bool)

Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId, bool skipExtendedSave)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
skipExtendedSave bool
If true; Extended Save of the Product is skipped. Default is false.

Returns

bool

SaveAndConfirm(Product, string, string, string)

Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId, string productLanguageId)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
productLanguageId string
The product language ID.

Returns

bool

SaveAndConfirm(Product, string, string, string, bool)

Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId, string productLanguageId, bool skipExtendedSave)

Parameters

product Product
productId string
The product ID.
productVariantId string
The product variant ID.
productLanguageId string
The product language ID.
skipExtendedSave bool
If true; Extended Save of the Product is skipped. Default is false.

Returns

bool

SetDefaultProductFields(Product)

Initializes or reinitializes the ProductFieldValues property with all current ProductFields in the system and null values. This method is explicitly called by the constructor.
public void SetDefaultProductFields(Product product)

Parameters

product Product

SetFieldValue(Product, ProductField, object)

Sets the product field value.
public void SetFieldValue(Product product, ProductField field, object value)

Parameters

product Product
field ProductField
value object

SetProductFieldValue(Product, string, object)

Gets the product field value.
public void SetProductFieldValue(Product product, string productFieldSystemName, object value)

Parameters

product Product
productFieldSystemName string
SystemName of the ProductField.
value object
The value to set.

Exceptions

ArgumentException
If not ProductField or ProductFieldValue exist based on the given SystemName.

UpdateCounters(Product)

Updates the variant and unit counters. Should be called after adding variants or units to a product through the API.
public void UpdateCounters(Product product)

Parameters

product Product

UpdateDefaultVariantId(Product, string)

Updates the default variant ID.
public int UpdateDefaultVariantId(Product product, string variantComboId)

Parameters

product Product
The product.
variantComboId string
The variant combo ID.

Returns

int

Examples

class MyPage : System.Web.UI.Page
{
public void VariantOptions(Product product)
{
string overwriteDefaultVarCombo = string.Empty;
if (Request["saveVariant"] == "1")
{
Dynamicweb.eCommerce.Variants.VariantCombinationCollection variantCombinationCollection = Dynamicweb.eCommerce.Variants.VariantCombination.getProductCombinations(product);
Product.UpdateVariantCnt(product, variantCombinationCollection.Count);
}
if (Request["saveDefaultVariant"] == "1")
{
if (!string.IsNullOrEmpty(Converter.ToString(Dynamicweb.Context.Current.Request("DefaultVariantComboID"))))
{
overwriteDefaultVarCombo = Converter.ToString(Dynamicweb.Context.Current.Request("DefaultVariantComboID"));
}
Product.UpdateDefaultVariantID(product, overwriteDefaultVarCombo);
}
}
}

UpdatePriceCount(Product, int)

Updates the price counter.
public int UpdatePriceCount(Product product, int priceCount)

Parameters

product Product
The product.
priceCount int
The price counter.

Returns

int

Examples

class MyPage : System.Web.UI.Page
{
public void StockForUnits(Product product)
{
if (Request["saveUnit"] == "1")
{
Dynamicweb.eCommerce.Prices.PriceCollection price = Dynamicweb.eCommerce.Prices.Price.getPrices(product.ID);
Product.UpdatePriceCount(product, price.Count);
}
}
}

UpdateStock(Order)

Updates the stock.
public int UpdateStock(Order order)

Parameters

order Order

Returns

int
The number of products that have had their Stock updated.

Examples

class MyPage : System.Web.UI.Page
{
private void DeleteOrders(string orderID)
{
Dynamicweb.eCommerce.Orders.OrderState deletedOrderState = null;

Check for a 'Deleted' Order state and use if exists
Dynamicweb.eCommerce.Orders.OrderStateCollection orderStates = Dynamicweb.eCommerce.Orders.OrderState.getAllOrderstates(false);
foreach (Dynamicweb.eCommerce.Orders.OrderState orderState in orderStates) {
if (orderState.IsDeleted) {
deletedOrderState = orderState;
}
}

Dynamicweb.eCommerce.Orders.Order order = Dynamicweb.eCommerce.Orders.Order.Create(orderID);
order.Deleted = true;
order.StateID = deletedOrderState.ID;
order.Save();

if (order.Complete)
{
Product.UpdateStock(order);
}
}
}

UpdateStock(Order, ProductOrderStockOperator)

Updates the stock.
public int UpdateStock(Order order, ProductOrderStockOperator @operator)

Parameters

order Order
operator ProductOrderStockOperator

Returns

int
The number of products that have had their Stock updated.

Examples

class MyPage : System.Web.UI.Page
{
private void DeleteOrders(string orderID)
{
Dynamicweb.eCommerce.Orders.OrderState deletedOrderState = null;

Check for a 'Deleted' Order state and use if exists
Dynamicweb.eCommerce.Orders.OrderStateCollection orderStates = Dynamicweb.eCommerce.Orders.OrderState.getAllOrderstates(false);
foreach (Dynamicweb.eCommerce.Orders.OrderState orderState in orderStates) {
if (orderState.IsDeleted) {
deletedOrderState = orderState;
}
}

Dynamicweb.eCommerce.Orders.Order order = Dynamicweb.eCommerce.Orders.Order.Create(orderID);
order.Deleted = true;
order.StateID = deletedOrderState.ID;
order.Save();

if (order.Complete)
{
Product.UpdateStock(order, Product.ProductOrderStockOperator.Positive);
}
}
}

UpdateStock(Order, ProductOrderStockOperator, StockLocation)

Updates the stock.
public int UpdateStock(Order order, ProductOrderStockOperator @operator, StockLocation stockLocation)

Parameters

order Order
operator ProductOrderStockOperator
The operator.
stockLocation StockLocation
The stock location.

Returns

int

UpdateStock(OrderLine, ProductOrderStockOperator)

Updates the stock.
public bool UpdateStock(OrderLine orderLine, ProductOrderStockOperator @operator)

Parameters

orderLine OrderLine
The orderLine.
operator ProductOrderStockOperator
The operator.

Returns

bool
Whether stock was updated or no.

UpdateStock(OrderLine, ProductOrderStockOperator, StockLocation)

Updates the stock.
public bool UpdateStock(OrderLine orderLine, ProductOrderStockOperator @operator, StockLocation stockLocation)

Parameters

orderLine OrderLine
The orderLine.
operator ProductOrderStockOperator
The operator.
stockLocation StockLocation
The stock location.

Returns

bool
Whether stock was updated or no.

UpdateUnitCount(Product, int)

Updates the unit counter.
public int UpdateUnitCount(Product product, int unitCount)

Parameters

product Product
The product.
unitCount int
The unit counter.

Returns

int

Examples

class MyPage : System.Web.UI.Page
{
private Product product;
public void StockForUnits(Product product)
{
if (Request["saveUnit"] == "1")
{
AddProdUnit(product);

Dynamicweb.eCommerce.Variants.VariantOptionCollection units = Dynamicweb.eCommerce.Variants.VariantOption.getVariantOptions(product, 1);
Product.UpdateUnitCount(product, units.Count);
}
}

private void AddProdUnit(Product product)
{
string reqName = null;
string reqValue = null;

if (Converter.ToInt32(product.Type) == 0)
{
Dynamicweb.eCommerce.Stocks.StockUnit su = new Dynamicweb.eCommerce.Stocks.StockUnit();
su.Delete(product.ID);

foreach (string item in Request.Form)
{
reqName = item.ToString();
reqValue = Request[item];

if (reqName.IndexOf("PRODUNIT_ID") == 0)
{
if (!string.IsNullOrEmpty(reqValue))
{
su.ProductID = product.ID;
su.VariantID = "";
su.UnitID = reqValue;
su.Save(product.ID, "", reqValue);
}
}
}
}
}
}

UpdateVariantCount(Product, int)

Updates the variant counter.
public int UpdateVariantCount(Product product, int variantCount)

Parameters

product Product
The product.
variantCount int
The variant counter.

Returns

int

Examples

class MyPage : System.Web.UI.Page
{
public void VariantOptions(Product product)
{
string overwriteDefaultVarCombo = string.Empty;
if (Request["saveVariant"] == "1")
{
Dynamicweb.eCommerce.Variants.VariantCombinationCollection variantCombinationCollection = Dynamicweb.eCommerce.Variants.VariantCombination.getProductCombinations(product);
Product.UpdateVariantCount(product, variantCombinationCollection.Count);
}
if (Request["saveDefaultVariant"] == "1")
{
if (!string.IsNullOrEmpty(Converter.ToString(Dynamicweb.Context.Current.Request("DefaultVariantComboID"))))
{
overwriteDefaultVarCombo = Converter.ToString(Dynamicweb.Context.Current.Request("DefaultVariantComboID"));
}
Product.UpdateDefaultVariantID(product, overwriteDefaultVarCombo);
}
}
}
To top