Developer forum

Forum » Development » Create new Group Programatically

Create new Group Programatically


Reply

Hi im trying to create a new Group as a subgroup of another group.

my code looks like this:

 

Group newDestination = new Group();
newDestination.Name = "Destination " + destination;
//newDestination.ParentID = rejser.ID;
 newDestination.LanguageID = "LANG1";
string latestGroupId = Database.getDataSet("SELECT GroupID FROM EcomGroups ORDER BY GroupID DESC", String.Empty).Tables[0].Rows[0][0].ToString();

 

string newGroupId = "Group" + Convert.ToInt32(latestGroupId.Replace("GROUP",""))+1;
newDestination.Save(newGroupId);
GroupRelation gr = new GroupRelation();
gr.ID = newGroupId;
gr.ParentID = rejser.ID;
gr.Save(newGroupId, rejser.ID);
return newDestination;

 

It is saved in the database and aparently looks like subgroups I created from the eCom module

 

But it isnt showed in the tree in the ecommerce module.

Is there some obscure table that I need to insert a value into or what?

 

- Sune Fengel.

 


Replies

 
Reply

Ok I found out I had to add the group to the group shop relational table.

 

- Sune

 

 
Reply

Hi Sune,

 

I posted an answer yesterday stating exactly that, but this is gone now. Glad you found out anyway. I made one additional point that you may have to run Dynamicweb.eCommerce.Common.Application.KillGroupTree in order to flush the cache of groups.

 
Reply
Sorensen wrote:

Hi Sune,

 

I posted an answer yesterday stating exactly that, but this is gone now. Glad you found out anyway. I made one additional point that you may have to run Dynamicweb.eCommerce.Common.Application.KillGroupTree in order to flush the cache of groups.

Ok thanks I'll be sure to do that.

 

- Sune

 

You must be logged in to post in the forum