Developer forum

Forum » Templates » Product list Razor

Product list Razor

Thomas Schroll
Reply

 

Hi

I hope someone can help.

I'm showing a list of all products, and on that list I'm trying to divide the product list into groups based on Ecom groups. In xslt I could loop through ProductGroups first, then loop through Products, and only display those products where ProductGroups.Group.Name was equal to AssociatedGroups.Group.Name. It was not a pretty solution but it worked.

When upgrading to 8.2.3.2 I could not use xslt (at least not the above), so I decided to use razor. Now I do not have access to the AssociatedGroup loop. Is there another way to get the AssociatedGroups loop? In xslt I should declare availableloops, is that also necessary in razor, and how do I do that? In the documentation for 8.2.3.2 there is an image (see attachment - http://developer.dynamicweb-cms.com/releases/dynamiceb-8.2.3.aspx) where the group is displayed, but it does not work in my template.

Furthermore, the @DwTemplateTag does not work as it used to. When used in the productlist template it only shows Global tags and loops. Is there another way to display available tags in razor?

Regards Thomas

 

 

DW823RazorTemplates.png

Replies

 
Dmitrij Jazel
Reply

Hej Thomas.

try using this:

@foreach (LoopItem i in GetLoop("Products"))
{
    <div>YOUR HTML...</div>
    @foreach (LoopItem i2 in GetLoop("AssociatedGroups")){
    // get all the Associated groups Loop stuff
    }
    <div>YOUR HTML...</div>
}

You should be able to call associated Groups loop when you are inside Products loop (my first guess).

When inside inner loop. Keep in mind the "i" and "i2" variables. You should use "i2" for accessing AssociatedGroups loop item information.

 

Hope this helps :) 

 

Dmitrij

 
Thomas Schroll
Reply

Hi Dmitrij

Thanks for your answer but it doesn't work. I've tried the following:

@foreach (LoopItem i in GetLoop("Products"))
{
    <div>produkt</div>
	@i.GetValue("Ecom:Product.Name");
    foreach (LoopItem i2 in GetLoop("AssociatedGroups")){
			 i2.GetValue("Ecom:Group.Name");
    <div>gruppe</div>
	<!--@DwTemplateTags-->
    }
}

What I see on the page is varying lines of the tekst 'produkt' and the product name. I don't get the tekst 'gruppe' and the group name. I've attached a screen dump of the available loops as shown by DwTemplateTags.

Regards Thomas

 

productlist.jpg

 

You must be logged in to post in the forum