Issue
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.
Solution
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, ' > '), ' > '), ' > '), ' > ')" />
Answered By - michael.hor257k Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.