tessguefen
3/25/2015 - 10:26 PM

Amazon Feed with Category Trails (using canonical)

Amazon Feed with Category Trails (using canonical)

<mvt:comment>
| Amazon Product Feed
| MyPaperShop Products
| File Output: /amazon_feed.txt
</mvt:comment>
<mvt:assign name="g.tab" value="asciichar(9)" />
<mvt:assign name="g.newline" value="asciichar(10)" />
<mvt:assign name="g.pipe" value="asciichar(124)" />
<mvt:assign name="g.comma" value="asciichar(44)" />
<mvt:assign name="g.quote" value="asciichar(34)" />
<mvt:assign name="g.period" value="asciichar(46)" />
<mvt:assign name="g.delimiter" value="asciichar(9)" />
<mvt:assign name="g.filename" value="'amazon_feed.txt'" />
<mvt:assign name="g.filepath" value="'/'" />
<mvt:assign name="g.headerrow" value="'Category' $ g.delimiter $
'Title' $ g.delimiter $
'Link' $ g.delimiter $
'SKU' $ g.delimiter $
'Price' $ g.delimiter $
'Brand' $ g.delimiter $
'Department' $ g.delimiter $
'UPC' $ g.delimiter $
'Image' $ g.delimiter $
'Description' $ g.delimiter $
'Manufacturer' $ g.delimiter $
'Mfr part number' $ g.delimiter $
'Bullet point1' $ g.delimiter $
'Bullet point2' $ g.delimiter $
'Bullet point3' $ g.delimiter $
'Bullet point4' $ g.delimiter $
'Bullet point5' $ g.delimiter $
'Color' $ g.delimiter $
'Item package quantity' $ g.delimiter $
'Keywords1' $ g.delimiter $
'Keywords2' $ g.delimiter $
'Keywords3' $ g.delimiter $
'Keywords4' $ g.delimiter $
'Keywords5' $ g.delimiter $
'Shipping Weight' $ g.newline" />
<mvt:comment>
    Delete File if it exists, create new file with header row
</mvt:comment>
<mvt:assign name="g.file_exists" value="sexists(g.filepath $ g.filename)" />
<mvt:if expr="g.file_exists EQ 1">
    <mvt:assign name="g.file_deleted" value="sdelete(g.filepath $ g.filename)" />
    <mvt:if expr="g.file_deleted EQ 1">
        <mvt:assign name="g.file_created" value="file_create(g.filepath $ g.filename,'script', g.headerrow)" />
    </mvt:if>
<mvt:else>
    <mvt:assign name="g.file_created" value="file_create(g.filepath $ g.filename,'script', g.headerrow)" />
</mvt:if>
<mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( 'amazonfeed', l.settings:current_category )" /> 
<mvt:do name="l.result" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:current_category:id, g.Offset, 9999, g.NextOffset, l.settings:products )" /> 
&mvt:global:headerrow;
<mvt:foreach iterator="product" array="products">
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code, 'az_cat_override, az_name_override, c_or_h, upc, casecountnumber, URLSTUB, amazonbullet1, amazonbullet2, amazonbullet3, amazonbullet4', l.settings:customfields )" />

	<mvt:if expr="NOT ISNULL l.settings:customfields:az_cat_override">
        <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:az_cat_override $ g.delimiter" />
    <mvt:else>
        <mvt:do name="l.whatever" file="g.Module_Library_DB" value="Category_Load_Id(l.settings:product:cancat_id, l.settings:canonical_category)" />
        <mvt:item name="toolkit" param="breadcrumb|b_count|l.all_settings:canonical_category:code" />
        <mvt:if expr="b_count GT 0">
            <mvt:assign name="ccounter" value="0" />
            <mvt:assign name="l.settings:categorytrail" value="''" />
            <mvt:foreach iterator="breadcrumb" array="breadcrumbs">
                <mvt:if expr="g.ccounter EQ 0">
                    <mvt:assign name="l.settings:categorytrail" value="l.settings:categorytrail $ l.settings:breadcrumb:name" />
                <mvt:else>
                  <mvt:assign name="l.settings:categorytrail" value="l.settings:categorytrail $ ' > ' $ l.settings:breadcrumb:name" />
                </mvt:if>
                <mvt:assign name="ccounter" value="g.ccounter + 1" />
            </mvt:foreach>
        </mvt:if>    
        <mvt:assign name="g.file_row" value="g.file_row $ l.settings:categorytrail $ g.delimiter" />
    </mvt:if>
    
    <mvt:if expr="NOT ISNULL l.settings:customfields:az_name_override">
         <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:az_name_override $ g.delimiter" />
    <mvt:else>
        <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:name $ g.delimiter" />
    </mvt:if>
    
    <mvt:assign name="g.file_row" value="g.file_row $ 'https://' $ g.domain:name $ '/' $ l.settings:product:code $ '/' $ l.settings:customfields:URLSTUB $ '.html' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:code $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:price $ g.delimiter" />
    
    <mvt:if expr="l.settings:customfields:c_or_h EQ 'H'">
        <mvt:assign name="g.file_row" value="g.file_row $ 'Hoffmaster' $ g.delimiter" />
    <mvt:else>
        <mvt:assign name="g.file_row" value="g.file_row $ 'Creative Converting' $ g.delimiter" />
    </mvt:if>
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:upc $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:code $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ 'https://' $ g.domain:name $ '/mm5/graphics/00000001/' $ l.settings:product:code $ '.jpg' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ ' ' $ g.delimiter" />
    
    <mvt:if expr="l.settings:customfields:c_or_h EQ 'H'">
        <mvt:assign name="g.file_row" value="g.file_row $ 'Hoffmaster' $ g.delimiter" />
    <mvt:else>
        <mvt:assign name="g.file_row" value="g.file_row $ 'Creative Converting' $ g.delimiter" />
    </mvt:if>
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:code $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:amazonbullet1 $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:amazonbullet2 $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:amazonbullet3 $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:amazonbullet4 $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:customfields:casecountnumber $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ '' $ g.delimiter" />
    
    <mvt:assign name="g.file_row" value="g.file_row $ l.settings:product:weight $ g.delimiter" />
    <mvt:assign name="g.file_row" value="g.file_row $ g.newline" />
</mvt:foreach>
 &mvt:global:file_row;
 <mvt:assign name="g.write_line" value="file_append( g.filepath $ g.filename, 'script', g.file_row )" />