html Miva Google Shopping Feed

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Miva Google Shopping Feed相关的知识,希望对你有一定的参考价值。

<!--
	FROM: https://gist.github.com/BrennanMiva/9cb20acb4be4d07bd51d
	Some things to note:
	- The feed can take a long time to run if you have a lot of product. You may have to increase your miva timeout.
	- This example does not use variants. If you needed variants exported you could add in toolkit variantarry function but this will add to the overall time the feed takes to run.
	- You’ll want to limit this page by IP address to prevent bots or unauthorized people from hitting it.
	- This is setup to output a file to the web root + whatever folder you define in the filepath variable
	- The script first checks for the existence of the file. It will delete it and create a new one every time the page is hit.
	- This page uses the sitemap item to iterate though all products of the site.
-->
<mvt:comment>
	| Google Shopping Feed
	| gm Products
	| File Output: /feeds/1978 - 1988GMG - Body.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="'1978-1988GMG-Body.txt'"/>
<mvt:assign name="g.filepath" value="'/feeds/'"/>
<mvt:assign name="g.headerrow" value="
					'link' 					$ g.delimiter $
					'title'  				$ g.delimiter $
					'description'	 		$ g.delimiter $
					'image_link' 			$ g.delimiter $
					'price' 				$ g.delimiter $
					'id' 					$ g.delimiter $
					'expiration_date'	 	$ g.delimiter $
					'brand' 				$ g.delimiter $
					'condition' 			$ g.delimiter $
					'product_type' 			$ g.delimiter $
					'availability' 			$ g.delimiter $
					'shipping_weight' 		$ g.delimiter $
					'mpn' 					$ g.delimiter $
					'identifier_exists'		$ 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:comment>Add 30 days to current day</mvt:comment>
<mvt:assign name="g.expiration_date" value="s.time_t + 2592000"/>
<mvt:assign name="l.settings:month" value="padl( time_t_month( g.expiration_date, 'local' ), 2, '0' )"/>
<mvt:assign name="l.settings:day" value="padl( time_t_dayofmonth( g.expiration_date, 'local' ), 2, '0' )"/>
<mvt:assign name="l.settings:year" value="time_t_year( g.expiration_date, 'local' )"/>
<mvt:assign name="g.formatted_expiration" value="l.settings:year $ '-' $ l.settings:month $ '-' $ l.settings:day"/>

<mvt:assign name="g.count" value="0"/>

<mvt:foreach iterator = "product" array = "products">
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'gm-name', g.gm_name)"/>
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'new_gm_description', g.gm_description)"/>
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'partnotes', g.partnotes)"/>
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'new_gm_applications', g.applications)"/>
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'google_product_type', g.product_type)"/>
	<mvt:item name="customfields" param = "Read_Product_Code(l.settings:product:code,'mpn', g.mpn)"/>

	<mvt:if expr="NOT ISNULL g.gm_name">
		<mvt:assign name="g.file_row" value="
						'http://' $ g.domain:name $ '/gm/' $ l.settings:product:code $ '.html' $ g.delimiter $
						g.gm_name $ g.delimiter $
						g.gm_description $ ' Part Notes: ' $ g.partnotes $ ' Applications: ' $ g.applications $ g.delimiter $
						'http://' $ g.domain:name $ '/mm5/' $ l.settings:product:image $ g.delimiter $
						l.settings:product:price	$ g.delimiter $
						l.settings:product:code		$ g.delimiter $
						g.formatted_expiration		$ g.delimiter $
						'N/A' 						$ g.delimiter $
						'new' 						$ g.delimiter $
						g.product_type 				$ g.delimiter $
						'available for order' 		$ g.delimiter $
						l.settings:product:weight 	$ g.delimiter $
						g.mpn 						$ g.delimiter $
						'FALSE'						$ g.newline"/>

		<mvt:assign name="g.write_line" value="file_append( g.filepath $ g.filename, 'script', g.file_row )"/>
		<mvt:assign name="g.count" value="g.count + 1"/>
	</mvt:if>

</mvt:foreach>

There were &mvte:global:count; products exported to this file: <br><br>
Car Type: &mvte:global:car_type; <br>
Feed Type: &mvte:global:feed_type; <br><br>

<a href="http://&mvte:global:domain:name;&mvte:global:filepath;&mvt:global:filename;" target="_blank"> http://&mvte:global:domain:name;&mvte:global:filepath;&mvt:global:filename; </a>

以上是关于html Miva Google Shopping Feed的主要内容,如果未能解决你的问题,请参考以下文章

html Miva - Google购物Feed - v2

html Miva - Google和Listrak数据Feed

html Miva - Google跟踪代码管理器数据层示例

xml Google Shopping.xml

xml Google Shopping.xml

通过 Python 访问 Google Shopping API