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
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
productProductproductToRelateProductrelatedProductGroupProductRelatedGroup
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
productIdstringrelatedProductProductrelatedProductGroupProductRelatedGroup
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
productProductvariantGroupVariantGroup- 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
Returns
CalculateVolume(Product)
public double CalculateVolume(Product product)
Parameters
productProduct
Returns
ChangeWorkflowState(Product, WorkflowState)
public void ChangeWorkflowState(Product product, WorkflowState workflowState)
Parameters
productProductworkflowStateWorkflowState
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
keyProductKey- 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
keysIEnumerable<ProductKey>- Keys to reset
Clone(Product)
Clones this instance.
public Product Clone(Product product)
Parameters
productProduct
Returns
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
productToCopyProduct- The product to copy
newProductIdstring- The product id of the new instance. If this is null or empty, a new product id will be generated
newVariantIdstring- The variant id of the new instance
Returns
CurrentBackendUserCanEdit(Product)
Checks if the current backend user has permission to edit a given product.
public bool CurrentBackendUserCanEdit(Product theProduct)
Parameters
theProductProduct- 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
productsIEnumerable<Product>
Returns
Delete(string, string)
public void Delete(string productId, string productVariantId = null)
Parameters
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
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
productsIEnumerable<Product>- The products.
doRunbool- if set to
trueexecute.
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
idsIEnumerable<string>- The list of IDs.
doRunbool- if set to
trueexecute.
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
productIdstring- DB field name is ProductID.
productVariantIdstring- DB field name is ProductVariantID.
productLanguageIdstring- DB field name is ProductLanguageID.
forceDeletebool
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
productsIEnumerable<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
productIdstring- DB field name is ProductID.
productVariantIdstring- 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
variantOptionGroupIdstring
Fill(ref Product, IDataReader)
Fills the properties from DataReader.
[Obsolete("Don't use")]
public void Fill(ref Product product, IDataReader dataReader)
Parameters
productProductdataReaderIDataReader- DataReader.
Fill(IDataReader)
Fills the properties from DataReader.
[Obsolete("Don't use")]
public void Fill(IDataReader dataReader)
Parameters
dataReaderIDataReader- DataReader.
GetActiveProducts(string, bool)
Gets the active products.
public IEnumerable<Product> GetActiveProducts(string productLanguageId, bool useAssortments)
Parameters
productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
Returns
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
shopIdstring- DB field name is ShopGroupShopID.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
doRefactoringbool- if set to
true; - do refactoring the product collection. productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
productIdstring- The product ID.
Returns
- IEnumerable<VersionData>
- The collection of the VersionData.
GetByAutoIDs(IList<long>)
public IEnumerable<Product> GetByAutoIDs(IList<long> autoIDs)
Parameters
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringpageNumberintpageSizeintsearchAllFieldsboolorderBystringassortmentIdstring
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringpageNumberintpageSizeintsearchAllFieldsboolorderBystringassortmentIdstringshopIdsIEnumerable<string>
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringpageNumberintpageSizeintsearchAllFieldsboolorderBystringassortmentIdstringshopIdsIEnumerable<string>shopTypeShopType?
Returns
GetByProductIDs(string[], bool, string, bool, bool)
public IEnumerable<Product> GetByProductIDs(string[] productIds, bool doRefactoring, string productLanguageId, bool bulkFill, bool useAssortments)
Parameters
Returns
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
idCombinationsList<Tuple<string, string>>productLanguageIdsIEnumerable<string>doRefactoringbooluseAssortmentsbool
Returns
GetByProductIDsAndVariantIDs(List<Tuple<string, string>>, string, bool, bool)
public IEnumerable<Product> GetByProductIDsAndVariantIDs(List<Tuple<string, string>> idCombinations, string productLanguageId, bool doRefactoring, bool useAssortments)
Parameters
idCombinationsList<Tuple<string, string>>productLanguageIdstringdoRefactoringbooluseAssortmentsbool
Returns
GetBySearchTerm(string, string, string)
[Obsolete]
public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID)
Parameters
Returns
GetBySearchTerm(string, string, string, IEnumerable<ShopType>)
public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID, IEnumerable<ShopType> shopTypes)
Parameters
searchValuestringgroupIDstringvariantIDstringshopTypesIEnumerable<ShopType>
Returns
GetBySearchTerm(string, string, string, IEnumerable<ShopType>, bool)
public IEnumerable<Product> GetBySearchTerm(string searchValue, string groupID, string variantID, IEnumerable<ShopType> shopTypes, bool searchInAllFields)
Parameters
searchValuestringgroupIDstringvariantIDstringshopTypesIEnumerable<ShopType>searchInAllFieldsbool
Returns
GetCommandBuilderConditionPartForIds(IEnumerable<Product>)
Gets the condition part of a SQL statement.
public CommandBuilder GetCommandBuilderConditionPartForIds(IEnumerable<Product> products)
Parameters
productsIEnumerable<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
idsIEnumerable<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
productsIEnumerable<Product>- The products.
Returns
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
masterProductProductshopShopgroupsIEnumerable<Group>
Returns
GetCountOfAllProductsWithoutVariants()
public int GetCountOfAllProductsWithoutVariants()
Returns
GetFieldValue(Product, ProductField)
Gets the product field value.
public ApplicationResponse<object> GetFieldValue(Product product, ProductField field)
Parameters
productProductfieldProductField
Returns
GetIdUrlEncoded(string)
Gets the ID URL encoded.
[Obsolete("System.Net.WebUtility.UrlEncode for encoding")]
public string GetIdUrlEncoded(string id)
Parameters
idstring
Returns
GetLastActiveProducts(int, string, bool)
Gets the last active products.
public IEnumerable<Product> GetLastActiveProducts(int count, string productLanguageId, bool useAssortments)
Parameters
countint- Select top from selected items.
productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
countint- Select top from selected items.
groupIdsstring[]- The array of group IDs.
productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
variantGroupVariantGroup- The VariantGroup object.
pageNumberintpageSizeint
Returns
GetProductById(string, string, bool)
Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, bool useDefaultLanguage)
Parameters
productIdstring- The product ID.
productVariantIdstring- The variant ID.
useDefaultLanguagebool- if set to
true[use default language].
Returns
GetProductById(string, string, string)
Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId)
Parameters
productIdstring- The product ID.
productVariantIdstring- The variant ID.
productLanguageIdstring- The language ID.
Returns
Remarks
When specified product with variant id and language not equal
Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageIDGetProductById(string, string, string, User)
Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, User user)
Parameters
productIdstring- The product ID.
productVariantIdstring- The variant ID.
productLanguageIdstring- The language ID.
userUser- User that needs access to the product
Returns
Remarks
When specified product with variant id and language not equal
Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageIDGetProductById(string, string, string, bool)
Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, bool useAssortments)
Parameters
productIdstring- The product ID.
productVariantIdstring- The variant ID.
productLanguageIdstring- The language ID.
useAssortmentsbool- If set to
trueuse assortments.
Returns
Remarks
When specified product with variant id and language not equal
Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageIDGetProductById(string, string, string, int)
Gets the product by ID.
public Product GetProductById(string productId, string productVariantId, string productLanguageId, int userId)
Parameters
productIdstring- The product ID.
productVariantIdstring- The variant ID.
productLanguageIdstring- The language ID.
userIdint
Returns
Remarks
When specified product with variant id and language not equal
Common.Context.LanguageID not found returns product with variant id from Common.Context.LanguageIDGetProductByKey(ProductKey)
public Product GetProductByKey(ProductKey productKey)
Parameters
productKeyProductKey
Returns
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
productNumberstring- Product number.
useDefaultLanguagebool- 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
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
variantGroupVariantGroup
Returns
GetProductDataSet()
Gets an empty DataSet that matches the database schema.
[Obsolete("Should exist in repository")]
public DataSet GetProductDataSet()
Returns
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
productIdstring- The product ID.
Returns
GetProductFieldValue(Product, string)
Gets the product field value.
public object GetProductFieldValue(Product product, string productFieldSystemName)
Parameters
productProductproductFieldSystemNamestring- SystemName of the ProductField.
Returns
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
productProduct- The product.
Returns
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
groupGroup- The group.
productLanguageIdstring- The language ID.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
groupIdstring- The group ID.
useOrderBybool- if set to
truethe returned collection of product is sorted by the user defined sort order. If set tofalsethe products are returned unsorted. includeVariantsbool- if set to
truegets all variants. productLanguageIdstring- The language ID.
doRefactoringbool- if set to
trueremove unused products. useAssortmentsbool- If set to
trueassortments are used to filter collection.
Returns
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
groupIdstring- The group ID.
onlyActivebool- if set to
trueremoves not active items from collection. productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter the collection.
Returns
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
groupIdstring- The group ID.
topintdoRefactoringbool- if set to
trueremoves not used items. productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are use to filter the collection.
Returns
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
groupIdstring- The group ID.
topValuestring- The top value.
searchValuestring- The search value.
productVariantIdstring- The variant ID.
Returns
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
groupIdstring- The group ID.
topValuestring- The top value, i.e. the number of products to get.
searchValuestring- The search value.
productVariantIdstring- The variant ID.
isFrontendbool- if set to
trueremoves not used items.
Returns
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
groupIdstring- The group ID.
topValuestring- The top value, i.e. the number of products to get.
searchValuestring- The search value.
productVariantIdstring- The variant ID.
isFrontendbool- if set to
trueremoves not used items. productLanguageIdstring- The language ID to use.
Returns
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
groupIdstring- The group ID.
topValuestring- The top value, i.e. the number of products to get.
searchValuestring- The search value.
productVariantIdstring- The variant ID.
isFrontendbool- if set to
trueremoves not used items. productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter collection.
Returns
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
groupsGroupCollection- The groups.
productLanguageIdstring- The language ID.
isFrontEndbool- if set to
trueremoves not used items. useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
productKeysIEnumerable<ProductKey>
Returns
GetProductsByNumber(string, string)
Gets a list of products by number.
public IEnumerable<Product> GetProductsByNumber(string productNumber, string productLanguageId)
Parameters
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
Returns
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
productProduct- The product.
productVariantIdstring- The variant ID.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
GetProductsByShopId(string, string, bool)
Gets products from shop.
public IEnumerable<Product> GetProductsByShopId(string shopId, string productLanguageId, bool useAssortments)
Parameters
shopIdstring- DB field name is ShopGroupShopID.
productLanguageIdstring- The language ID to use.
useAssortmentsbool- If set to
trueassortments are used to filter products.
Returns
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
useAssortmentsbool- if set to
trueassortments are used to filter the product collection. querystring- The SQL query.
Returns
GetProductsBySql(string)
Gets the ProductCollection object.
[Obsolete("Don't use")]
public IEnumerable<Product> GetProductsBySql(string query)
Parameters
querystring- The SQL query.
Returns
GetProductsBySql(string, bool)
Gets the ProductCollection object.
[Obsolete("Don't use")]
public IEnumerable<Product> GetProductsBySql(string query, bool doRefactoring)
Parameters
querystring- The SQL query.
doRefactoringbool- if set to
trueremoves products that are not in stock, do not have a price (0), or is not active, or is not in a current assortments.
Returns
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
querystring- The SQL.
doRefactoringbool- if set to
trueremoves products that are not in stock, do not have a price (0), or is not active, or is not in a current assortments. bulkFillbool- if set to
true[bulk fill].
Returns
GetProductsByVariantGroup(VariantGroup)
Gets the products.
public IEnumerable<Product> GetProductsByVariantGroup(VariantGroup variantGroup)
Parameters
variantGroupVariantGroup- The VariantGroup object.
Returns
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
groupIdstring- The group ID.
countOnlyActivebool- if set to
truecount only active products. searchValuestring- The search value.
productLanguageIdstring- The language ID.
includeVariantsbool- if set to
truegets all variants. doRefactoringbool- if set to
trueremove unused products.
Returns
GetProductsCountByGroupId(string, string, string, bool, bool)
Gets the products count.
public int GetProductsCountByGroupId(string groupId, string searchValue, string productLanguageId, bool includeVariants, bool doRefactoring)
Parameters
groupIdstring- The group ID.
searchValuestring- The search value.
productLanguageIdstring- The language ID.
includeVariantsbool- if set to
truegets all variants. doRefactoringbool- if set to
trueremove unused products.
Returns
GetProductsIds(IEnumerable<Product>)
Returns list of IDs.
public IEnumerable<string> GetProductsIds(IEnumerable<Product> products)
Parameters
productsIEnumerable<Product>- The products.
Returns
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
Returns
GetRelatedCountFrontend(Product)
Gets the RelatedProducts counting.
[Obsolete("Use overload with currency, country, stocklocation, user")]
public int GetRelatedCountFrontend(Product product)
Parameters
productProduct
Returns
GetRelatedCountFrontend(Product, Currency, Country, StockLocation, User)
public int GetRelatedCountFrontend(Product product, Currency currency, Country country, StockLocation stockLocation, User user)
Parameters
productProductcurrencyCurrencycountryCountrystockLocationStockLocationuserUser
Returns
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
productProduct
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringuseVariantsboolsearchInAllFieldsboolonlyActiveProductsboolassortmentIdstring
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringuseVariantsboolsearchInAllFieldsboolonlyActiveProductsboolassortmentIdstringshopIdsIEnumerable<string>
Returns
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
searchTextstringuseBackCatalogboolshowProductsstringuseVariantsboolsearchInAllFieldsboolonlyActiveProductsboolassortmentIdstringshopIdsIEnumerable<string>shopTypeShopType?
Returns
GetSqlConditionPartForIDs(IEnumerable<Product>)
[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(IEnumerable<Product> products)
Parameters
productsIEnumerable<Product>
Returns
GetSqlConditionPartForIDs(IEnumerable<string>)
[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(IEnumerable<string> ids)
Parameters
idsIEnumerable<string>
Returns
GetSqlConditionPartForIDs(string)
Gets the condition part of a SQL statement.
[Obsolete("Use GetCommandBuilderConditionPartForIds method instead.")]
public string GetSqlConditionPartForIDs(string idList)
Parameters
idListstring- 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
productProduct
Returns
GetStockStatus(Product, StockLocation)
Gets the stock status.
public StockStatus GetStockStatus(Product product, StockLocation stockLocation)
Parameters
productProductstockLocationStockLocation
Returns
GetStockStatus(Product, StockLocation, string)
Gets the stock status.
public StockStatus GetStockStatus(Product product, StockLocation stockLocation, string unitId)
Parameters
productProductstockLocationStockLocationunitIdstring
Returns
GetStockStatus(Product, double)
Gets the stock status.
public StockStatus GetStockStatus(Product product, double unitStock)
Parameters
Returns
GetStockStatus(Product, string)
[Obsolete("Use GetStockStatus(Product) instead.")]
public StockStatus GetStockStatus(Product product, string productLanguageId)
Parameters
Returns
GetVersionProduct(VersionData)
Gets product which stored in versionData.
public Product GetVersionProduct(VersionData version)
Parameters
versionVersionData- 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
productProduct
Returns
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
productProduct
Returns
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
languageIdstring
Returns
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
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
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
productProduct- The product.
groupIdstring- The group ID.
productLanguageIdstring- The language ID.
newProductIdstring- 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
productIdstring- The product ID.
groupIdstring- The group ID.
productLanguageIdstring- The language ID.
newProductIdstring- 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
Returns
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
productsICollection<Product>currencyCurrencycountryCountrystockLocationStockLocationuserUseruseAssortmentsbool- If set to
truethen 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
productsICollection<Product>useAssortmentsbool- If set to
truethen 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
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
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
productProductvariantGroupVariantGroup- 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
productProductvariantGroupVariantGroup- 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
productProduct
Save(Product, bool)
Saves this instance.
public void Save(Product product, bool skipExtendedSave)
Parameters
productProductskipExtendedSavebool- 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
Save(Product, string, string, bool)
Saves this instance.
public void Save(Product product, string productId, string productVariantId, bool skipExtendedSave)
Parameters
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
skipExtendedSavebool- 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
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
productLanguageIdstring- 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
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
productLanguageIdstring- The product language ID.
skipExtendedSavebool- 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
productProductproductIdstring- DB field name is ProductID.
productVariantIdstring- DB field name is ProductVariantID.
Returns
SaveAndConfirm(Product, string, string, bool)
Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId, bool skipExtendedSave)
Parameters
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
skipExtendedSavebool- If true; Extended Save of the Product is skipped. Default is false.
Returns
SaveAndConfirm(Product, string, string, string)
Saves this instance and confirms it.
public bool SaveAndConfirm(Product product, string productId, string productVariantId, string productLanguageId)
Parameters
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
productLanguageIdstring- The product language ID.
Returns
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
productProductproductIdstring- The product ID.
productVariantIdstring- The product variant ID.
productLanguageIdstring- The product language ID.
skipExtendedSavebool- If true; Extended Save of the Product is skipped. Default is false.
Returns
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
productProduct
SetFieldValue(Product, ProductField, object)
Sets the product field value.
public void SetFieldValue(Product product, ProductField field, object value)
Parameters
productProductfieldProductFieldvalueobject
SetProductFieldValue(Product, string, object)
Gets the product field value.
public void SetProductFieldValue(Product product, string productFieldSystemName, object value)
Parameters
productProductproductFieldSystemNamestring- SystemName of the ProductField.
valueobject- 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
productProduct
UpdateDefaultVariantId(Product, string)
Updates the default variant ID.
public int UpdateDefaultVariantId(Product product, string variantComboId)
Parameters
Returns
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
Returns
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
orderOrder
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
orderOrderoperatorProductOrderStockOperator
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
orderOrderoperatorProductOrderStockOperator- The operator.
stockLocationStockLocation- The stock location.
Returns
UpdateStock(OrderLine, ProductOrderStockOperator)
Updates the stock.
public bool UpdateStock(OrderLine orderLine, ProductOrderStockOperator @operator)
Parameters
orderLineOrderLine- The orderLine.
operatorProductOrderStockOperator- 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
orderLineOrderLine- The orderLine.
operatorProductOrderStockOperator- The operator.
stockLocationStockLocation- 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
Returns
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
Returns
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);
}
}
}