Create Custom Feed Using Product Listing Item#
Description#
Create your own Custom Feed using the product listing item, and save to file.
Snippet#
<mvt:comment>
<!--
Google Shopping Feed: Product Data Feed
Regen URL: http://www.MYWEBSITEHERE.com/PAGECODEHERE.html?continue=refresh&auth=swhj23089ruSAD (FOR MANUAL UPDATE)
Regen URL (cron): http://www.MYWEBSITEHERE.com/PAGECODEHERE.html?auth=swhj23089ruSAD
File Output: http://www.MYWEBSITEHERE.com/feeds/SA_products.csv
-->
</mvt:comment>
<mvt:if expr="g.auth NE 'swhj23089ruSAD'">
Access Denied
<mvt:exit />
</mvt:if>
<mvt:assign name="g.newline" value="asciichar(10)" />
<mvt:assign name="g.delimiter" value="asciichar(9)" />
<mvt:if expr="ISNULL g.filename">
<mvt:assign name="g.filename" value="'SA_products.csv'" />
</mvt:if>
<mvt:assign name="g.filepath" value="'/feeds/'" />
<mvt:assign name="g.headerrow" value="
'link' $ g.delimiter $
'name' $ g.delimiter $
'image' $ g.delimiter $
'price' $ g.delimiter $
'code' $ g.newline
" />
<mvt:comment><!-- Delete File if it exists, create new file with header row --></mvt:comment>
<mvt:if expr="ISNULL g.Per_Page">
<mvt:assign name="g.Per_Page" value="500" />
</mvt:if>
<mvt:if expr="ISNULL g.AllOffset">
<mvt:assign name="g.AllOffset" value="0" />
</mvt:if>
<mvt:if expr="l.settings:all_products:page_links:current_page EQ 1">
<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:if>
<mvt:comment><!-- Loop over all of the products --></mvt:comment>
<mvt:foreach iterator="product" array="all_products:products">
<mvt:assign name="g.file_row" value="'http://www.MYWEBSITEHERE.com/' $ l.settings:product:code $ '.html' $ g.delimiter $ l.settings:product:name $ g.delimiter $ g.cleandescrip $ g.delimiter" />
<mvt:if expr="l.settings:product:imagetypes:main">
<mvt:assign name="g.file_row" value=" g.file_row $ 'http://' $ g.domain:name $ '/mm5/' $ encodeentities(l.settings:product:imagetypes:main) $ g.delimiter" />
<mvt:else>
<mvt:assign name="g.file_row" value=" g.file_row $ 'http://' $ g.domain:name $ '/mm5/' $ encodeentities(l.settings:product:image) $ g.delimiter" />
</mvt:if>
<mvt:assign name="g.file_row" value=" g.file_row $ 'http://www.MYWEBSITEHERE.com/mm5/' $ l.settings:product:image $ g.delimiter $ l.settings:product:price $ g.delimiter $ l.settings:product:code $ g.newline" />
<mvt:assign name="g.write_line" value="file_append( g.filepath $ g.filename, 'script', g.file_row )" />
</mvt:foreach>
<mvt:if expr="l.settings:all_products:page_links:current_page LT l.settings:all_products:page_links:last_page">
Processed
<mvt:eval expr="miva_array_elements(l.settings:all_products:products) + g.Offset" /> Products...
<mvt:if expr="g.continue EQ 'refresh'">
<mvt:assign name="g.next_url" value="l.settings:all_products:page_links:next_link $ '&start=' $ g.start $ '&continue=refresh&auth=' $ g.auth" />
<meta http-equiv="refresh" content="0;URL='&mvt:global:next_url;'" />
<mvt:else>
<mvt:assign name="g.next_url" value="l.settings:all_products:page_links:next_link $ '&start=' $ g.start $ '&auth=' $ g.auth" />
<mvt:assign name="l.header" value="miva_output_header( 'Status', '301 Moved Permanently' )" />
<mvt:assign name="l.header" value="miva_output_header( 'Location', g.next_url )" />
</mvt:if>
<mvt:else>
Complete. <mvt:eval expr="'<a href=\"' $ g.filepath $ g.filename $ ' \">Download</a>'" />
</mvt:if>