Dynamicweb.eCommerce.Products Namespace > Product Class : AddVariantGroup Method |
'Declaration
Public Sub AddVariantGroup( _ ByVal variantGroup As VariantGroup _ )
public void AddVariantGroup( VariantGroup variantGroup )
class MyPage : System.Web.UI.Page { private void AddVariantGrpProdRelated() { Product prod = new Product(); prod = (Product)Session["Ecom.Backend.Product"]; string varGrpID = HttpContext.Current.Request.QueryString["grpArr"]; bool addRelation = false; Dynamicweb.eCommerce.Variants.VariantGroup variantGrp = Dynamicweb.eCommerce.Variants.VariantGroup.Create(varGrpID); if (!prod.VariantGroups.Contains(variantGrp, true)) { addRelation = true; prod.AddVariantGroup(variantGrp); } if (addRelation) { Dynamicweb.eCommerce.Variants.VariantGroupProductRelation vgpr = new Dynamicweb.eCommerce.Variants.VariantGroupProductRelation(prod.ID, varGrpID); try { vgpr.ProductID = prod.ID; vgpr.VariantGroupID = varGrpID; vgpr.Save(prod.ID, varGrpID); } catch (Exception ex) { //Nothing } } } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2