Developer forum

Forum » Development » Related products in XSLT template

Related products in XSLT template


Reply
I would like to use an XSLT template for a product detail page.
The page must include related products, grouped by the related product groups.

So far I have managed to show the related product groups and their names.
Example:

<xsl:for-each select="loop[@name='ProductRelatedGroups']/item">
  <h2>
    <xsl:value-of select="Ecom.Product.RelatedGroup.Name"/>
  </h2>
</xsl:for-each>

However I can't figure out how to show a list of related product for each group.

I tried to make it in an HTML template, convert it to XSLT - but that didn't work.

Example (no product output)
<xsl:for-each select="loop[@name='ProductRelatedGroups']/item">
  <h2>
    <xsl:value-of select="Ecom.Product.RelatedGroup.Name"/>
  </h2>
  <xsl:for-each select="loop[@name='Products']/item">
    <xsl:value-of select="Ecom.Product.Link" disable-output-escaping="yes"/>
  </xsl:for-each>
</xsl:for-each>

Replies

 
Nicolai Høeg Pedersen
Reply
You have to be aware of the availableloops thing for xslt templates - especially in ecommerce templates.

<xsl:variable name="availableloops" select="'Details,VariantCombinations,BOMProducts,ProductRelatedGroups,RelatedProducts'" />

It is needed to tell the template engine which loops are required. This is a performance thing - so only add the loops you need in your code.

Attached a sample product template implementation in xslt that does render related groups etc.
 
Reply
Thanks

 

You must be logged in to post in the forum