Class Group
- Namespace
- Dynamicweb.Ecommerce.Products
- Assembly
- Dynamicweb.Ecommerce.dll
Product group class
[Serializable]
public class Group : IPermissionCustomAncestors, IDisplayName, IPermissionLookup, IPermissionControlled
- Inheritance
-
Group
- Implements
- Inherited Members
Constructors
Group()
Initializes new instance of the class.
public Group()
Properties
Assortment
Defines if a group belongs to assortment group.
public bool Assortment { get; set; }
Property Value
CachedOrderLineFields
Gets or sets the order line fields collection cached in current session.
[Obsolete("No longer used.")]
public OrderLineFieldCollection CachedOrderLineFields { get; set; }
Property Value
CachedOrderLineFieldsWithoutInheritance
Gets or sets the order line fields collection without inherited from parent groups, cached in current session.
[Obsolete("No longer used.")]
public OrderLineFieldCollection CachedOrderLineFieldsWithoutInheritance { get; set; }
Property Value
Category
Gets or sets the default category for this group and all language versions.
public Category Category { get; set; }
Property Value
CategoryFieldValues
public Dictionary<string, FieldValueCollection> CategoryFieldValues { get; set; }
Property Value
CompletionLanguages
Gets Language collection used for calculating the shop product completeness value.
public IEnumerable<Language> CompletionLanguages { get; }
Property Value
- IEnumerable<Language>
- Return Language collection
CompletionRules
Gets rules collection used for calculating the group product completeness value.
public IEnumerable<CompletionRule> CompletionRules { get; }
Property Value
- IEnumerable<CompletionRule>
- Return CompletionRule collection
Remarks
To assign rules to a group use
Description
Gets or sets the group description.
public string Description { get; set; }
Property Value
HasChildGroups
Defines if a group includes child elements.
[Obsolete("Use Services.ProductGroups.HasSubgroups instead.")]
public bool HasChildGroups { get; }
Property Value
Icon
Gets or sets the group icon.
public string Icon { get; set; }
Property Value
Id
Gets or sets the group ID.
public string Id { get; set; }
Property Value
IdUrlEncoded
Gets the ID URL encoded.
[Obsolete("Use System.Net.WebUtility.UrlEncode(Id) instead.")]
public string IdUrlEncoded { get; }
Property Value
InheritCategoryFieldsFromParent
Gets or sets value indicating whether to inherit product category fields from parent group[s].
public bool InheritCategoryFieldsFromParent { get; set; }
Property Value
Remarks
When property is true, the group should inherit Product Category field from parents(in a direct line).
If the group both have selected a product category And have the 'Inherit fields from parents',
the set of fields which is available in the group,
should a be a the combined set of fields from the selected Product Category and all product category fields from the parent.
Also the fields from the parents parent, if it is set to inherit field.
InheritOrderLineFields
Determines whether order line fields should be included from parent groups or not.
public bool InheritOrderLineFields { get; set; }
Property Value
IsTopGroup
Determines is current group a top group - resides at top level of groups tree.
public bool IsTopGroup { get; }
Property Value
LanguageId
Gets or sets the language ID.
public string LanguageId { get; set; }
Property Value
LargeImage
Gets or sets the large group image.
public string LargeImage { get; set; }
Property Value
ManufacturerId
Gets or sets the default value for manufacturer ID property of child products.
public string ManufacturerId { get; set; }
Property Value
Meta
Gets or sets meta data.
public GroupMetaData Meta { get; set; }
Property Value
Name
Gets or sets the group name.
public string Name { get; set; }
Property Value
NavigationClickable
Determines whether the current group is clickable in navigation.
public bool NavigationClickable { get; set; }
Property Value
NavigationShowInMenu
Determines whether group should be shown in navigation menu or not.
public bool NavigationShowInMenu { get; set; }
Property Value
NavigationShowInSiteMap
Determines whether group should be shown in site map or not.
public bool NavigationShowInSiteMap { get; set; }
Property Value
Number
Gets or sets the group number.
public string Number { get; set; }
Property Value
OrderLineFields
Gets the order line fields collection.
public OrderLineFieldCollection OrderLineFields { get; }
Property Value
OrderLineFieldsWithoutInheritance
Gets the order line fields collection without inherited from parent groups.
public OrderLineFieldCollection OrderLineFieldsWithoutInheritance { get; }
Property Value
PageIdRelation
Gets or sets the relation to a page by specifying an ID.
public int PageIdRelation { get; set; }
Property Value
Remarks
Deprecated...
ParentGroups
Get list of parent groups.
public GroupCollection ParentGroups { get; }
Property Value
ParentGroupsDefaultLanguage
Gets the list of parent groups in current or default language.
public GroupCollection ParentGroupsDefaultLanguage { get; }
Property Value
PrimaryParentGroupId
Get the ID of primary parent group.
public string PrimaryParentGroupId { get; }
Property Value
ProductCount
Gets products count in groups for current language, without variants.
public int ProductCount { get; }
Property Value
ProductCountForBackendTree
Gets products count in group for current language, without variants.
[Obsolete("Use Services.ProductGroups.GetProductCountForBackendTree instead.")]
public int ProductCountForBackendTree { get; }
Property Value
ProductGroupFieldValues
Gets or sets the list of custom fields values.
public ProductGroupFieldValueCollection ProductGroupFieldValues { get; set; }
Property Value
ProductRelationRuleField1
Condition field to make it possible to automatically assign products to one or more groups.
public string ProductRelationRuleField1 { get; set; }
Property Value
ProductRelationRuleField2
Condition field to make it possible to automatically assign products to one or more groups.
public string ProductRelationRuleField2 { get; set; }
Property Value
ProductRelationRuleValue1
Condition value to make it possible to automatically assign products to one or more groups.
public string ProductRelationRuleValue1 { get; set; }
Property Value
ProductRelationRuleValue2
Condition value to make it possible to automatically assign products to one or more groups.
public string ProductRelationRuleValue2 { get; set; }
Property Value
Products
Gets or sets the products in this group.
public ProductCollection Products { get; set; }
Property Value
ProductsByLanguage
Gets or sets the products by language.
public ProductCollection ProductsByLanguage { get; set; }
Property Value
ProductsByLanguageWithOutVariants
Gets or sets the products in this group by language without variants.
public ProductCollection ProductsByLanguageWithOutVariants { get; set; }
Property Value
ProductsByLanguageWithOutVariantsCount
Gets the products count in this group by language without variants.
public int ProductsByLanguageWithOutVariantsCount { get; }
Property Value
ProductsWithOutVariants
Products in this group without variants.
public ProductCollection ProductsWithOutVariants { get; }
Property Value
ProductType
Gets or sets the default value for product type property of child products.
public int ProductType { get; set; }
Property Value
RelatedGroupIds
Gets the string with list of related groups. Related groups are used as default list of related groups for child products.
public string RelatedGroupIds { get; set; }
Property Value
- string
- Related group ids, delimited by "#;#"
RelatedGroups
Gets the list of related groups. Related groups are used as default list of related groups for child products.
public GroupCollection RelatedGroups { get; }
Property Value
ShopId
Gets or sets the ID of shop for current group.
public string ShopId { get; set; }
Property Value
Shops
Gets the shops for current group.
public IEnumerable<Shop> Shops { get; }
Property Value
SmallImage
Gets or sets the small group image.
public string SmallImage { get; set; }
Property Value
StockGroupId
Gets or sets the default value for stock group ID property of child products.
public string StockGroupId { get; set; }
Property Value
Subgroups
Gets the list of child groups with current context language.
[Obsolete("Use Services.ProductGroups.GetSubgroups instead.")]
public GroupCollection Subgroups { get; }
Property Value
SubgroupsDefaultLanguage
Gets the list of child groups in current or default language.
[Obsolete("Use Services.ProductGroups.GetUntranslatedSubgroups instead.")]
public GroupCollection SubgroupsDefaultLanguage { get; }
Property Value
Type
Gets or sets the group type GroupType.
public GroupType Type { get; set; }
Property Value
UntranslatedSubgroups
Gets the list of child groups in all languages.
[Obsolete("Use Services.ProductGroups.GetUntranslatedSubgroups instead.")]
public GroupCollection UntranslatedSubgroups { get; }
Property Value
VatGroupId
Gets or sets the default value for VAT group ID property of child products.
public string VatGroupId { get; set; }
Property Value
WorkflowId
public int WorkflowId { get; set; }
Property Value
Methods
AddRelatedProductId(string, string)
Adds the default related product to relation group.
[Obsolete("Use Services.ProductGroups.AddRelatedProductId instead.")]
public void AddRelatedProductId(string relatedGroupId, string productId)
Parameters
AddRelatedProductId(string, string, string)
Adds the default related product to relation group.
[Obsolete("Use Services.ProductGroups.AddRelatedProductId instead.")]
public void AddRelatedProductId(string relatedGroupId, string productId, string variantId)
Parameters
relatedGroupId
string- The relation group ID.
productId
string- The product ID.
variantId
string- The variant ID.
AddSubgroup(Group)
[Obsolete("Use Services.ProductGroups.AddSubgroup instead")]
public void AddSubgroup(Group subgroup)
Parameters
subgroup
Group- The subgroup.
Examples
using Dynamicweb.Ecommerce.Extensibility.Controls;
using Dynamicweb.Ecommerce.Products;
using System.Collections.Generic;
namespace Dynamicweb.Ecommerce.Examples
{
public class GroupAddSubgroupSample
{
public void CreateNewGroupsAndNestAsSubgroup()
{
// Create a new Group that will be the parent group
var parentGroup = new Group();
parentGroup.Name = "Parent group";
// Create a new Group that will be the subgroup
var subgroup = new Group();
subgroup.Name = "Subgroup";
// Save both groups to the database before creating relations
parentGroup.Save();
subgroup.Save();
// Create nesting relation
parentGroup.AddSubgroup(subgroup);
}
public string GetCallToActionMarkup(string groupLink)
{
var match = System.Text.RegularExpressions.Regex.Match(groupLink, @"GroupID=(?<GroupID>[^&]+)");
if (match.Success)
{
var groupId = match.Groups["GroupID"].Value;
var g = Dynamicweb.Ecommerce.Products.Group.GetGroupById(groupId);
if (g != null && !string.IsNullOrEmpty(Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaHeading").Value)))
{
var ctaHeading = Dynamicweb.Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaHeading").Value);
var ctaText = Dynamicweb.Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaText").Value);
var ctaImage = Dynamicweb.Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaImage").Value);
var ctaLink = Dynamicweb.Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaLink").Value);
var ctaLinkText = Dynamicweb.Core.Converter.ToString(g.ProductGroupFieldValues.GetProductGroupFieldValue("CtaLinkText").Value);
return string.Format("<h3>{0}</h3><div>{1}</div><img src=\"{2}\" /><a href=\"{3}\" class=\"btn\">{4}</a>", ctaHeading, ctaText, ctaImage, ctaLink, ctaLinkText);
}
}
return string.Empty;
}
public string GetNavigationMarkup()
{
var rootPages = Dynamicweb.Services.Pages.GetRootPagesForArea(Dynamicweb.Frontend.PageView.Current().AreaID);
return GetNavigationMarkupOneLevel(rootPages);
}
public string GetNavigationMarkupOneLevel(System.Collections.Generic.IEnumerable<Dynamicweb.Content.Page> pages)
{
if(pages == null)
{
return string.Empty;
}
var markup = new System.Text.StringBuilder();
markup.AppendLine("<ul>");
foreach (var p in pages)
{
markup.AppendLine("<li>");
markup.AppendLine(p.MenuText);
//Stop navigation in level 2
if(p.Level < 2)
{
markup.AppendLine(GetNavigationMarkupOneLevel(Dynamicweb.Services.Pages.GetPagesByParentID(p.ID)));
}
//Check if this page has a navigation provider for Ecommerce and render the groups
if (p.NavigationSettings != null && p.NavigationSettings.UseEcomGroups)
{
ProductsAndGroupsHandler groupHandler = new ProductsAndGroupsHandler(p.NavigationSettings.Groups);
markup.AppendLine(GetNavigationMarkupForGroups(groupHandler.GroupsSelected, 1));
}
markup.AppendLine("</li>");
}
markup.AppendLine("</ul>");
return markup.ToString();
}
public string GetNavigationMarkupForGroups(IEnumerable<Group> groups, int level)
{
var markup = new System.Text.StringBuilder();
markup.AppendLine("<ul>");
foreach (var g in groups)
{
markup.AppendLine("<li>");
markup.AppendLine(g.Name);
//Only include 2 levels of ecommerce groups
if (level < 2)
{
markup.AppendLine(GetNavigationMarkupForGroups(g.Subgroups, level+1));
}
markup.AppendLine("</li>");
}
markup.AppendLine("</ul>");
return markup.ToString();
}
}
}
Exceptions
- ArgumentException
- If this instance is not saved first.
- ArgumentException
- If the subgroup is not saved first.
ClearCache()
Clears all the product group cache.
[Obsolete("Use Services.ProductGroups.ClearCache instead.")]
public static void ClearCache()
ClearCache(bool)
Clears the product group cache.
[Obsolete("Use Services.ProductGroups.ClearCache() instead.")]
public static void ClearCache(bool clearAssortmentsnavigationCache)
Parameters
clearAssortmentsnavigationCache
bool- The indicator whether to clear assortment navigation cache also.
ClearOrderLineFieldCache()
Clears order line fields cache.
[Obsolete("No longer used. Cached fields are cleared when fields or field relations are saved.")]
public void ClearOrderLineFieldCache()
Clone()
Creates in-memory copy of current group.
public Group Clone()
Returns
- Group
- The copy of the group.
Copy()
Creates and saves to database a copy of current group.
public Group Copy()
Returns
- Group
- The copy of the group.
Copy(string, string)
Creates and saves to database a copy of current group with specified group ID and language ID.
public Group Copy(string groupId, string groupLanguageId)
Parameters
Returns
- Group
- The copy of the group.
Delete()
Deletes the current group from database.
[Obsolete("Use Services.ProductGroups.Delete instead")]
public void Delete()
Delete(GroupCollection)
Deletes all groups from provided collection.
[Obsolete("Use Services.ProductGroups.Delete instead.")]
public static string Delete(GroupCollection groups)
Parameters
groups
GroupCollection- The groups collection to delete.
Returns
- string
- Empty string.
Delete(GroupCollection, bool)
Prepares SQL statement to delete groups from provided collection and optionally execute this statement.
[Obsolete("Use Services.ProductGroups.Delete instead.")]
public static string Delete(GroupCollection groups, bool run)
Parameters
groups
GroupCollection- The groups collection to delete.
run
bool- Determines whether the delete statement should be executed or not.
Returns
- string
- Empty string.
Delete(string)
Deletes the group from database using group ID.
[Obsolete("Use Services.ProductGroups.Delete instead")]
public static void Delete(string groupId)
Parameters
groupId
string- The group ID to delete.
Delete(string, string)
Deletes the group from database using group ID and language ID.
[Obsolete("Use Services.ProductGroups.Delete instead")]
public static void Delete(string groupId, string groupLanguageId)
Parameters
DeleteAll(GroupCollection, bool)
Prepares SQL statement to delete groups from provided collection and optionally execute this statement.
Deletes appropriate relations between shops, other groups and products as well.
[Obsolete("Use Services.ProductGroups.DeleteAll instead.")]
public static string DeleteAll(GroupCollection groups, bool run)
Parameters
groups
GroupCollection- The groups collection to delete.
run
bool- Determines whether the delete statement should be executed or not.
Returns
- string
- Empty string.
DeleteRelatedProductId(string, string)
Deletes the related product from relation.
[Obsolete("Use Services.ProductGroups.DeleteRelatedProductId instead.")]
public void DeleteRelatedProductId(string relatedGroupId, string productId)
Parameters
DeleteRelatedProductId(string, string, string)
Deletes the related product from relation.
[Obsolete("Use Services.ProductGroups.DeleteRelatedProductId instead.")]
public void DeleteRelatedProductId(string relatedGroupId, string productId, string variantId)
Parameters
relatedGroupId
string- The relation group ID.
productId
string- The product ID to delete.
variantId
string- The product variant ID to delete.
DeleteRelatedProducts(string)
Deletes the related products from relation group.
[Obsolete("Use Services.ProductGroups.DeleteRelatedProducts instead.")]
public void DeleteRelatedProducts(string relatedGroupId)
Parameters
relatedGroupId
string- The relation group ID.
get_Granted(UserPermissionRights)
Determines have a current user specified permission for current group.
[Obsolete("Use GetPermission instead")]
public bool get_Granted(UserPermissionRights permission)
Parameters
permission
UserPermissionRights- Permission to check.
Returns
- bool
- Granted or not boolean flag.
GetAllGroups()
Gets all product groups sorted by name.
[Obsolete("Use Services.ProductGroups.GetGroups instead.")]
public static GroupCollection GetAllGroups()
Returns
GetAncestors(string[])
Defines how ancestors can be resolved from a specified path.
public List<IPermissionControlled> GetAncestors(string[] path)
Parameters
path
string[]- Path if identifiers
Returns
- List<IPermissionControlled>
- ancestors
GetByKey(string)
Can be used to look up a concrete object based upon the key.
public IPermissionControlled GetByKey(string key)
Parameters
key
string- Identifier
Returns
- IPermissionControlled
- permissionControlled
GetDisplayName()
Yields a human-readable name for rendering.
public string GetDisplayName()
Returns
- string
- name
GetEmptyGroupDataSet()
Returns an empty dataset from the Group table - used for looking at the columns.
[Obsolete("Use Dynamicweb.Data.Database.CreateDataSet instead.")]
public static DataSet GetEmptyGroupDataSet()
Returns
GetGranted(UserPermissionRights)
Determines have a current user specified permission for current group.
[Obsolete("Use GetPermission instead")]
public bool GetGranted(UserPermissionRights permission)
Parameters
permission
UserPermissionRights- Permission to check.
Returns
GetGroupById(string)
Gets the group by ID.
[Obsolete("Use Services.ProductGroups.GetGroup instead.")]
public static Group GetGroupById(string groupId)
Parameters
groupId
string- The group ID.
Returns
- Group
- The group.
GetGroupById(string, bool)
Gets the group by ID.
[Obsolete("Use Services.ProductGroups.GetGroup instead.")]
public static Group GetGroupById(string groupId, bool showUntranslated)
Parameters
Returns
- Group
- The group.
GetGroupById(string, string)
Gets the group by ID.
[Obsolete("Use Services.ProductGroups.GetGroup instead.")]
public static Group GetGroupById(string groupId, string grouplanguageId)
Parameters
Returns
- Group
- The group.
GetGroupsByIDs(IEnumerable<string>)
Gets groups by provided group IDs.
[Obsolete("Use Services.ProductGroups.GetGroups instead.")]
public static GroupCollection GetGroupsByIDs(IEnumerable<string> groupIds)
Parameters
groupIds
IEnumerable<string>- The list of group IDs.
Returns
GetGroupsByIDs(IEnumerable<string>, bool)
Retrieves a list of groups by their IDs with an option to filter results by current language and/or permissions.
[Obsolete("Use Services.ProductGroups.GetGroups instead.")]
public static GroupCollection GetGroupsByIDs(IEnumerable<string> groupIds, bool applyFiltering)
Parameters
groupIds
IEnumerable<string>- The list of group IDs.
applyFiltering
bool- The filter results by current language and/or permissions.
Returns
GetGroupsByProduct(Product)
Gets the groups for given product.
[Obsolete("Use ProductGroupRelation.GetProductGroupRelations instead.")]
public static GroupCollection GetGroupsByProduct(Product prod)
Parameters
prod
Product- The product.
Returns
GetGroupsBySearchWord(string, int)
Finds the topCounter groups using given keyword.
[Obsolete("Use Services.ProductGroups.FindGroups instead.")]
public static GroupCollection GetGroupsBySearchWord(string keyword, int topCounter)
Parameters
Returns
GetGroupsBySearchWord(string, int, string)
Finds the topCounter groups using given keyword and shop ID.
[Obsolete("Use Services.ProductGroups.FindGroups instead.")]
public static GroupCollection GetGroupsBySearchWord(string keyword, int topCounter, string shopId)
Parameters
keyword
string- The keyword to find.
topCounter
int- The maximum number of returned results.
shopId
string- The shop ID to search in.
Returns
GetParent()
Gets the parent of this object, for the purposes of inherited permissions.
public IPermissionControlled GetParent()
Returns
- IPermissionControlled
- parent
Remarks
Return null, if no parent permissions exist
GetPermissionIdentifier()
Combination of values that form a unique identifier.
public UnifiedPermissionIdentifier GetPermissionIdentifier()
Returns
- UnifiedPermissionIdentifier
- Unique identifier.
GetRelatedProductIds(string)
Gets the string with list of related products for relation group. Related products are used as default list of related products for child products.
[Obsolete("Use Services.ProductGroups.GetRelatedProductIds instead.")]
public string GetRelatedProductIds(string relatedGroupId)
Parameters
relatedGroupId
string
Returns
- string
- Related product ids, delimited by "#;#"
GetRelatedProducts(string)
Gets the list of related products for relation group. Related products are used as default list of related products for child products.
[Obsolete("Use Services.ProductGroups.GetRelatedProducts instead.")]
public ProductCollection GetRelatedProducts(string relatedGroupId)
Parameters
relatedGroupId
string- relation group ID
Returns
- ProductCollection
- Related products collection
GetSubgroups()
Gets the subgroups for this Group in the same language as the group.
[Obsolete("Use Services.ProductGroups.GetSubgroups instead.")]
public GroupCollection GetSubgroups()
Returns
GetSubgroups(string)
Gets the subgroups for the Group in the specified language.
[Obsolete("Use Services.ProductGroups.GetSubgroups instead.")]
public GroupCollection GetSubgroups(string languageId)
Parameters
languageId
string
Returns
GetToplevelGroups()
Gets the top level groups.
[Obsolete("Use Services.ProductGroups.GetToplevelGroups instead.")]
public static GroupCollection GetToplevelGroups()
Returns
GetToplevelGroups(string)
Gets the top level groups in specified language.
[Obsolete("Use Services.ProductGroups.GetToplevelGroups instead.")]
public static GroupCollection GetToplevelGroups(string languageId)
Parameters
languageId
string- The language ID.
Returns
HasProducts()
Determines has this group products or not.
[Obsolete("Use Services.ProductGroups.HasProducts instead.")]
public bool HasProducts()
Returns
HasProducts(Group)
Determines has this group products or not.
[Obsolete("Use Services.ProductGroups.HasProducts instead.")]
public static bool HasProducts(Group group)
Parameters
group
Group- The group to check.
Returns
- bool
True
if group has products, otherwise,False
.
Save()
Saves this instance.
[Obsolete("Use Services.ProductGroups.Save instead.")]
public void Save()
Save(string)
Saves the group using provided group ID.
[Obsolete("Use Services.ProductGroups.Save instead.")]
public void Save(string groupId)
Parameters
groupId
string- The group ID.
Save(string, string)
Saves the group using provided group ID and language ID.
[Obsolete("Use Services.ProductGroups.Save instead.")]
public void Save(string groupId, string groupLanguageId)
Parameters
SetCategoryFieldValue(Field, object)
public bool SetCategoryFieldValue(Field field, object value)
Parameters
Returns
UpdateGroupId(string, string)
Updates group id value in all tables where this column is present.
[Obsolete("Use Services.ProductGroups.UpdateGroupId instead.")]
public static void UpdateGroupId(string oldGroupId, string newGroupId)
Parameters
WhereClauseBuilder(GroupCollection)
Builds a comma separated string of group ids, for where statements.
[Obsolete]
public static string WhereClauseBuilder(GroupCollection groups)
Parameters
groups
GroupCollection- The GroupCollection.
Returns
- string
- The string of the group IDs separated by comma.