Shortening an output file name using XSLT in Magento
First of all, please accept my apologies if I say stupid things in my post1 I really don't understand this programming language and have only got so far through trial and error!
Here is my xsl template so far:
<?xml version="1.0"?>
<files>
<file filename="%lastincrementid%.txt">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:output method="text"/>
<xsl:variable name="sepstart" select="'"'"/> <!-- " field start seperator, including '' -->
<xsl:variable name="sepend" select="'",'"/> <!-- field end seperator, including '' -->
<xsl:template match="/">
<xsl:for-each select="orders/order">
<xsl:for-each select="items/item">
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(sku)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(qty)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(price)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(row_total)"/><xsl:value-of select="$sepend" />
<xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../increment_id)"/><xsl:value-of select="$sepend" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</file>
</files>
The format of %lastincrementid% is a 9 digit number such as 100007654.
The filename is currently set to be this 9 digit number BUT I want it to be only the last 4 digits, ie 7654.
Can anyone please be kind enough to show me how I go about it? I would be eternally grateful........ :-)
Last edited by Rachel Moore; August 2nd, 2016 at 11:26 AM..
|