Developer forum

Forum » Templates » Primary Group as a tag

Primary Group as a tag

Kim SĂžjborg Pedersen
Reply

Hi, I can set the primary group on a produkt, but how do I use it, is there a template tag?

The goal is to show the produkt on its primary group regardless of the list it appears in as well as the canonical part of it.

 

 

 

 


Replies

 
Morten Bengtson
Reply

If you need the id of the primary group id in your template, you should be able to render it by using this template tag:

 

<!--@Ecom:Product.PrimaryGroupID-->

 

 

You can use it like this:

<!--@If Defined(Ecom:Product.PrimaryGroupID)-->
	<a href="Default.aspx?ID=<!--@Global:Page.ID-->&GroupID=<!--@Ecom:Product.PrimaryGroupID-->&ProductID=<!--@Ecom:Product.ID-->"><!--@Ecom:Product.Name--></a>
<!--@Else-->
	<!--@Ecom:Product.LinkGroup-->
<!--@EndIf-->

 

 

 
Morten Bengtson
Reply

In addition to selecting a primary group on a product you can also select a primary page on a group.

However, it doesn't seem like you have that page id available in a separate template tag, so if you need to display a product using the primary group AND on the primary page then you can do something like this:

<!--@If Defined(Ecom:Product.PrimaryGroupID)-->
	<!--@LoopStart(AssociatedGroups)-->
		<!--@If(Ecom:Group.ID=Parent(Ecom:Product.PrimaryGroupID))-->
		<a href="<!--@Ecom:Group.Link.Clean-->&ProductID=<!--@Parent(Ecom:Product.ID)-->"><!--@Parent(Ecom:Product.Name)--></a>
		<!--@EndIf-->
	<!--@LoopEnd(AssociatedGroups)-->
<!--@Else-->
	<!--@Ecom:Product.LinkGroup-->
<!--@EndIf-->

 

 

 

You must be logged in to post in the forum