Dynamicweb 8 Documentation
AddVariantGroup Method
Example 

The VariantGroup object.
Adds the variant group.
Syntax
'Declaration
 
Public Sub AddVariantGroup( _ 
   ByVal variantGroup As VariantGroup _ 
) 
public void AddVariantGroup( 
   VariantGroup variantGroup 
)

Parameters

variantGroup
The VariantGroup object.
Example
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
           }
       }
   }
}
Requirements

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

See Also

Reference

Product Class
Product Members

Send Feedback