Developer forum

Forum » Templates » Set sort order

Set sort order

Per Ljung
Reply
Hi!

Is there a way to assign set the sort order of a product group using the xslt-files in the Import/Export module? There are two files that take care of the product group import from eg. NAV, /Integration/eCommerce/XSLT/ProductGroups.xslt and ProductGroupsExt.xslt.

Is there a way to set sort order in one of these files or any other file used during import?

Best regards,
P

Replies

 
Vladimir
Reply
Hi!
Do you tried to use <xsl:sort> element?
For example, in ProductGroupsExt.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <Categories>
      <xsl:apply-templates select="/Categories/Category">
      <xsl:sort select="@Name"/>
      </xsl:apply-templates>
    </Categories>
  </xsl:template>

Best regards,
Vladimir

 
Per Ljung
Reply
Hi!
Do you tried to use <xsl:sort> element?
For example, in ProductGroupsExt.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <Categories>
      <xsl:apply-templates select="/Categories/Category">
      <xsl:sort select="@Name"/>
      </xsl:apply-templates>
    </Categories>
  </xsl:template>

Best regards,
Vladimir

No, it didn't work.

/Per
 
Per Ljung
Reply
Hi!
Do you tried to use <xsl:sort> element?
For example, in ProductGroupsExt.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <Categories>
      <xsl:apply-templates select="/Categories/Category">
      <xsl:sort select="@Name"/>
      </xsl:apply-templates>
    </Categories>
  </xsl:template>

Best regards,
Vladimir

I think it would be better if I could use sorting in the xslt-code for the menu, all i need is the ID of the groups.
    /Per


 
Vladimir
Reply
Yes indeed, sorting is a little harder than I expected ...
First of all, there are two kinds of groups - a  top-level group (whose ancestor is shop) and subgroups. The sorting for them, is realized by different methods.
The file ProductGroups.xslt:
for the first:
    <Groups>
      <Group>
         ....
        <Shop>
          <ID>SHOP1</ID>
          <SortOrder>nnn</SortOrder>
        </Shop>
(where nnn is your preffered sort order for group)

for the second:
    <Groups>
      <Group>
         ....
          <ParentGroups>
            <ParentGroup>
              <ID><xsl:value-of select="@ParentID"/>@@<xsl:value-of select="@ShopID"/></ID>
              <SortOrder>nnn</SortOrder>
            </ParentGroup>
          </ParentGroups>

Altough should to tell, the top groups are not yet able to sort, because of a bug in the code - I registered it to fix asap.

Vladimir

 

You must be logged in to post in the forum