Magento 2 Export

<?xml version="1.0" encoding="UTF-8"?>
<files>
<file filename="%exportid%_order_export.csv">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:output method="text" encoding="UTF-8"/>

<xsl:variable name="sepstart" select="'&#34;'"/> <!-- &#34; field start seperator, including '' -->
<xsl:variable name="sepend" select="'&#34;,'"/> <!-- field end seperator, including '' -->

<xsl:template match="/">
<xsl:text>"OrderId","OrderDate","PayAmount" , "PayMethod" ,"CustomerId","DelAddress1", "DelAddress2" ,"DelTown" , "DelRegion" ,"DelPostcode", "AccAddress1", "AccAddess2", "AccTown", "AccRegion", "AccPostcode" ,"Tel1", "Tel2" ,"Email", "LineId" , "SKU", "OrderQty" , "UnitPriceExVAT" ,"UnitPriceIncVAT" ,"VATRate" , "Description", "First Name", "Last Name" </xsl:text><xsl:text>&#xD;&#xA;</xsl:text>

    <xsl:for-each select="orders/order">
                <xsl:if test="not(product_type='configurable')">
            <xsl:for-each select="items/item">
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(../../increment_id)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="php:functionString('strftime', '%m/%d/%Y', ../../created_at_timestamp)"/><xsl:value-of select="$sepend" />
            </xsl:for-each>
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(grand_total)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(payment/method)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(customer_id)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(shipping/street)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(shipping/city)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(shipping/region)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(shipping/postcode)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(billing/street)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(billing/city)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(billing/region)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(billing/postcode)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(shipping/telephone)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(customer_email)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="$sepend" />
            <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(round(qty_ordered))"/><xsl:value-of select="$sepend" />
            </xsl:for-each>            

                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(subtotal)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(grand_total)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" />20%<xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(customer_firstname)"/><xsl:value-of select="$sepend" />
                        <xsl:value-of select="$sepstart" /><xsl:value-of select="normalize-space(customer_lastname)"/><xsl:value-of select="$sepend" />


                </xsl:if>





    </xsl:for-each>
    <xsl:text>&#xD;&#xA;</xsl:text>
</xsl:template>
</xsl:stylesheet>
</file>
</files>

Did you find this article valuable?

Support Mandeep Singh Blog by becoming a sponsor. Any amount is appreciated!