Developer forum

Forum » Development » Group names from a product list template?

Group names from a product list template?


Reply
Hi

I need to make a select box that shows group names followed by its products, but I can´t get the group items from my product list template.


I tried this:


but to no use.

anybody knows hows to achieve this?

Replies

 
Reply
 Hello Antonio,
 
I don't completely understand your task, but I have created two examples. I hope it will be usefull.
 
Get all group names for current product in product list:
 
public class ProductTemplateExtender1 : ProductTemplateExtender
    {
        public override void ExtendTemplate(Dynamicweb.Templatev2.Template template)
        {
            GroupCollection groups = this.Product.Groups;
 
            List names = new List(groups.Count);
            foreach (Group g in groups)
            {
                names.Add(g.Name);
            }
 
            string namesStr = string.Join(",", names.ToArray());
 
            //todo: insert code here
        }
    }
 
Get all groups in product list:
 
public class ProductListTemplateExtender1 : ProductListTemplateExtender
    {
        public override void ExtendTemplate(Dynamicweb.Templatev2.Template template)
        {
            Dictionary allGroups = new Dictionary();
            foreach (Product product in this.ProductList)
            {
                foreach (Group g in product.Groups)
                {
                    if (!allGroups.ContainsKey(g.ID))
                    {
                        allGroups.Add(g.ID, g);
                    }
                }
            }
 
            //todo: insert your code here
        }
    }

-- Dmitry
 
Reply
Hi Dimitri 

Thanks for the reply, I am a frontender
so my task have to solved via frontend.

I used the availableloops variable , trying to catch the name of Product groups available on the shop but to no use.

I included my xslt and the save template file.

Thanks for the help!


 

You must be logged in to post in the forum