0

I'm trying to generate a product feed with Xtento Product export on magento and I can't get the product_type to show the value of the third position.

Can you give me a hand with this?

The code:

<!--product_type -->
            <xsl:element name="product_type">
                <xsl:choose>
                 <xsl:when test="string(xtento_mapped_category)"><xsl:value-of select="xtento_mapped_category"/></xsl:when> 
                <xsl:when test="string(cats/cat[children_count=0]/path_name)">
                <xsl:value-of select="substring-after(substring-after(cats/cat[children_count=0]/path_name,'>'),' > ')" />
                </xsl:when>
                <xsl:otherwise>
                <xsl:value-of select="substring-after(substring-after(parent_item/cats/cat[children_count=0]/path_name,'>'),' > ')" />
                </xsl:otherwise>
                </xsl:choose>
            </xsl:element>

Output product_type: Women > Undies > Thong Underwear > Cotton Thong Underwear

It should be just "Thong Underwear" or the 3rth position of the string.

ovadt
  • 3
  • 1
  • 1
    Which XSLT processor are you using? If you're not sure, find out: https://stackoverflow.com/a/25245033/3016153 – michael.hor257k Mar 30 '21 at 16:21
  • Thank you for providing a part of your code, but we need also an input sample and the corresponding output you want to be able to help you. It should be good that you provide a complete subset of your code that we could run for reproducing your problem. – Pierre François Mar 30 '21 at 16:28

1 Answers1

0

Given a string that contains:

alpha > bravo > charlie > delta

the following expression:

<xsl:value-of select="substring-before(substring-after(substring-after($your-string, ' > '), ' > '), ' > ')" />

will return:

charlie

Note that this assumes that the third token is not the last token of the given string. If you cannot be sure of that, then use:

<xsl:value-of select="substring-before(substring-after(substring-after(concat($your-string, ' > '), ' > '), ' > '), ' > ')" />
michael.hor257k
  • 113,275
  • 6
  • 33
  • 51