xml Miva - 自定义SearchSpring Feed
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml Miva - 自定义SearchSpring Feed相关的知识,希望对你有一定的参考价值。
<mvt:comment>
<!--
SearchSpring: Product Data Feed
File Output: /searchspring/searchspring_miva_dev.txt
SS Regeneration URL: http://www.mfdevsite.com/searchspring-feed.html?file_name=searchspring_miva_ubjx1m.txt&AllOffset=@offset
-->
</mvt:comment>
<mvt:assign name="g.tab" value="asciichar(9)"/>
<mvt:assign name="g.newline" value="asciichar(10)"/>
<mvt:assign name="g.return" value="asciichar(13)"/>
<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:if expr="ISNULL g.file_name">
<mvt:assign name="g.file_name" value="'searchspring_miva_dev.txt'"/>
</mvt:if>
<mvt:assign name="g.file_path" value="'/searchspring/'"/>
<mvt:assign name="g.header_row" value="
'code' $ g.delimiter $
'name' $ g.delimiter $
'description' $ g.delimiter $
'price' $ g.delimiter $
'formatted_price' $ g.delimiter $
'originalPrice' $ g.delimiter $
'formatted_originalPrice' $ g.delimiter $
'image' $ g.delimiter $
'image_view01' $ g.delimiter $
'sales_rank' $ g.delimiter $
'category_codes' $ g.delimiter $
'hierarchy' $ g.delimiter $
'variant_codes' $ g.delimiter $
'inlineStyle' $ g.delimiter $
'collection' $ g.delimiter $
'ssForWho' $ g.delimiter $
'ssOccasionsSeasons' $ g.delimiter $
'ssCategory' $ g.delimiter $
'ssType' $ g.delimiter $
'hasVariants' $ g.delimiter $
'isEnsemble' $ g.delimiter $
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="100" />
</mvt:if>
<mvt:if expr="ISNULL g.AllOffset">
<mvt:assign name="g.AllOffset" value="0" />
</mvt:if>
<mvt:if expr="g.AllOffset LT g.Per_Page">
<mvt:assign name="g.file_exists" value="sexists(g.file_path $ g.file_name)"/>
<mvt:if expr="g.file_exists EQ 1">
<mvt:assign name="g.file_deleted" value="sdelete(g.file_path $ g.file_name)"/>
<mvt:if expr="g.file_deleted EQ 1">
<mvt:assign name="g.file_created" value="file_create(g.file_path $ g.file_name,'script', g.header_row)"/>
</mvt:if>
<mvt:else>
<mvt:assign name="g.file_created" value="file_create(g.file_path $ g.file_name,'script', g.header_row)"/>
</mvt:if>
</mvt:if>
<mvt:comment><!-- Loop over all of the products --></mvt:comment>
<mvt:foreach iterator="product" array="all_products:products">
<mvt:if expr="'|' $ l.settings:product:code $ '|' CIN '|3118|3119|3157|1000|advertisement|TEST|mivatest|found-insert|hive-insert|heir-insert|animals-insert|amulets-insert|armament-insert|bamboo-insert|banana-insert|charms-insert|conserv-insert|corall-insert|crowns-insert|cruxx-insert|dynamics-insert|fdl-insert|fences-insert|fog-insert|gemma-insert|gulfstream-insert|hearts-insert|ironworks-insert|jh-insert|knots-insert|lily-insert|louisiana-insert|lucky-insert|luz-insert|opus-insert|orb-insert|particles-insert|peppers-insert|pylon-insert|romanesque-insert|rosa-insert|schema-insert|sea-insert|snoball-insert|symmetry-insert|tannen-insert|tulips-insert|whimsies-insert|zea-insert|fdl-set|tiger-set|9212Y|test|'">
<mvt:item name="customfields" param="Write_Product_ID(l.settings:product:id, 'excludeFromSearchSpring', 'yes')" />
<mvt:foreachcontinue/>
</mvt:if>
<mvt:comment><!-- Don't add product to feed if it is excluded from searchspring by custom field --></mvt:comment>
<mvt:if expr="l.settings:product:customfields:customfield_values:excludeFromSearchSpring">
<mvt:foreachcontinue/>
</mvt:if>
<mvt:comment><!-- Get category hierarchy --></mvt:comment>
<mvt:item name="toolkit" param="productincategory|incatcount|l.all_settings:product:code" />
<mvt:if expr="incatcount GT 0">
<mvt:foreach iterator="incategory" array="incategories">
<mvt:if expr="l.settings:product:cf:category_codes">
<mvt:assign name="l.settings:product:cf:category_codes" value="l.settings:product:cf:category_codes $ ',' $ l.settings:incategory:code" />
<mvt:else>
<mvt:assign name="l.settings:product:cf:category_codes" value="l.settings:incategory:code" />
</mvt:if>
<mvt:item name="toolkit" param="breadcrumb|b_count|l.all_settings:incategory:code" />
<mvt:if expr="g.b_count GT 0">
<mvt:foreach iterator="breadcrumb" array="breadcrumbs">
<mvt:if expr="l.settings:incategory:hierarchy">
<mvt:assign name="l.settings:incategory:hierarchy" value="l.settings:incategory:hierarchy $ '/' $ l.settings:breadcrumb:code" />
<mvt:else>
<mvt:assign name="l.settings:incategory:hierarchy" value="l.settings:breadcrumb:code" />
</mvt:if>
<mvt:if expr="l.settings:product:cf:hierarchy">
<mvt:assign name="l.settings:product:cf:hierarchy" value="l.settings:product:cf:hierarchy $ ',' $ l.settings:incategory:hierarchy" />
<mvt:else>
<mvt:assign name="l.settings:product:cf:hierarchy" value="l.settings:incategory:hierarchy" />
</mvt:if>
</mvt:foreach>
</mvt:if>
</mvt:foreach>
</mvt:if>
<mvt:comment><!-- Pricing --></mvt:comment>
<mvt:item name="toolkit" param="variantarray|vcount|l.all_settings:product:code" />
<mvt:if expr="g.vcount">
<mvt:assign name="l.settings:product:cf:hasVariants" value="1" />
<mvt:assign name="l.settings:product:lowest_variant:price" value="999999999" />
<mvt:assign name="l.settings:product:lowest_variant:originalPrice" value="999999999" />
<mvt:foreach iterator="variant" array="variants">
<mvt:if expr="l.settings:product:cf:variant_codes">
<mvt:assign name="l.settings:product:cf:variant_codes" value="l.settings:product:cf:variant_codes $ ',' $ l.settings:variant:code" />
<mvt:else>
<mvt:assign name="l.settings:product:cf:variant_codes" value="l.settings:variant:code" />
</mvt:if>
<mvt:if expr="l.settings:variant:price LT l.settings:product:lowest_variant:price">
<mvt:assign name="l.settings:product:lowest_variant:price" value="l.settings:variant:price" />
<mvt:item name="customfields" param="Read_Product_Code(l.settings:variant:code,'originalPrice', l.settings:variant:originalPrice)" />
<mvt:if expr="l.settings:variant:originalPrice AND l.settings:variant:originalPrice LT l.settings:product:lowest_variant:originalPrice">
<mvt:assign name="l.settings:product:lowest_variant:originalPrice" value="l.settings:variant:originalPrice" />
</mvt:if>
</mvt:if>
</mvt:foreach>
<mvt:assign name="l.settings:product:variants" value="l.settings:variants" />
<mvt:if expr="l.settings:product:lowest_variant:price LT 999999999">
<mvt:assign name="l.settings:product:price" value="l.settings:product:lowest_variant:price" />
</mvt:if>
<mvt:if expr="l.settings:product:lowest_variant:originalPrice LT 999999999">
<mvt:assign name="l.settings:product:customfield_values:customfields:originalPrice" value="l.settings:product:lowest_variant:originalPrice" />
</mvt:if>
</mvt:if>
<mvt:do name="l.settings:product:formatted_price" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:product:price )" />
<mvt:do name="l.settings:product:customfield_values:customfields:formatted_originalPrice" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:product:customfield_values:customfields:originalPrice )" />
<mvt:if expr="gettoken( l.settings:product:formatted_price, '.', 2 ) EQ '00'">
<mvt:assign name="l.settings:product:formatted_price" value="gettoken( l.settings:product:formatted_price, '.', 1 )"/>
<mvt:else>
<mvt:assign name="l.settings:product:formatted_price" value="l.settings:product:formatted_price"/>
</mvt:if>
<mvt:if expr="gettoken( l.settings:product:customfield_values:customfields:formatted_originalPrice, '.', 2 ) EQ '00'">
<mvt:assign name="l.settings:product:customfield_values:customfields:formatted_originalPrice" value="gettoken( l.settings:product:customfield_values:customfields:formatted_originalPrice, '.', 1 )"/>
<mvt:else>
<mvt:assign name="l.settings:product:customfield_values:customfields:formatted_originalPrice" value="l.settings:product:customfield_values:customfields:formatted_originalPrice"/>
</mvt:if>
<mvt:if expr="l.settings:product:customfield_values:customfields:formatted_originalPrice EQ '$0'">
<mvt:assign name="l.settings:product:customfield_values:customfields:formatted_originalPrice" value="''" />
</mvt:if>
<mvt:item name="toolkit" param="related|related_count|g.Product_Code" />
<mvt:if expr="g.related_count GT 0">
<mvt:assign name="l.settings:product:cf:isEnsemble" value="1" />
</mvt:if>
<mvt:comment><!-- Look Up Brand and SalesRank --></mvt:comment>
<mvt:comment>
<!--
<mvt:assign name="g.sql_select" value="'SELECT stats.counter FROM ' $ g.store_table_prefix $ 'SS_SPProducts sp LEFT JOIN ' $ g.store_table_prefix $ 'ProdStats stats ON sp.product_id = stats.product_id WHERE sp.product_id = ' $ l.settings:product:id" />
<mvt:item name="ry_toolbelt" param="query|g.sql_select|results" />
<mvt:assign name="l.settings:product:salesrank" value="l.settings:results[1]:counter" />
<mvt:if expr="isdigit(l.settings:product:customfield_values:customfields:salesRankBoost)">
<mvt:assign name="l.settings:product:salesrank" value="l.settings:product:salesrank + l.settings:product:customfield_values:customfields:salesRankBoost" />
</mvt:if>
-->
</mvt:comment>
<mvt:comment><!-- Clean Description --></mvt:comment>
<mvt:assign name="l.settings:product:descrip" value="glosub( l.settings:product:descrip, g.newline, '' )" />
<mvt:assign name="l.settings:product:descrip" value="glosub( l.settings:product:descrip, g.tab, '' )" />
<mvt:assign name="l.settings:product:descrip" value="glosub( l.settings:product:descrip, g.return, '' )" />
<mvt:comment><!-- Write File Row --></mvt:comment>
<mvt:assign name="g.file_row" value="
l.settings:product:code $ g.delimiter $
l.settings:product:name $ g.delimiter $
l.settings:product:descrip $ g.delimiter $
l.settings:product:price $ g.delimiter $
l.settings:product:formatted_price $ g.delimiter $
l.settings:product:customfield_values:customfields:originalPrice $ g.delimiter $
l.settings:product:customfield_values:customfields:formatted_originalPrice $ g.delimiter $
l.settings:product:imagetypes:main $ g.delimiter $
l.settings:product:imagetypes:view01 $ g.delimiter $
l.settings:product:cf:_sales_rank $ g.delimiter $
l.settings:product:cf:category_codes $ g.delimiter $
l.settings:product:cf:hierarchy $ g.delimiter $
l.settings:product:cf:variant_codes $ g.delimiter $
l.settings:product:customfield_values:customfields:prodbackgroundstylecode $ g.delimiter $
l.settings:product:customfield_values:customfields:collection $ g.delimiter $
l.settings:product:customfield_values:customfields:ssForWho $ g.delimiter $
l.settings:product:customfield_values:customfields:ssOccasionsSeasons $ g.delimiter $
l.settings:product:customfield_values:customfields:ssCategory $ g.delimiter $
l.settings:product:customfield_values:customfields:ssType $ g.delimiter $
l.settings:product:cf:hasVariants $ g.delimiter $
l.settings:product:cf:isEnsemble $ g.delimiter $
g.newline
"/>
<mvt:if expr="'debug' CIN g.output">
<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:product), ',', '<br>'))" /><hr>
<mvt:else>
<mvt:assign name="g.write_line" value="file_append( g.file_path $ g.file_name, 'script', g.file_row )"/>
</mvt:if>
</mvt:foreach>
<mvt:comment><!-- Output Response for SearchSpring Crawler --></mvt:comment>
<mvt:if expr="g.AllNextOffset GT 0">
<mvt:assign name="g.next_url" value="'http://' $ g.domain:name $ '/searchspring-feed.html?AllOffset=' $ g.AllNextOffset $ '&output=' $ g.output $ '&continue=' $ g.continue $ '&file_name=' $ g.file_name" />
Continue|&mvt:global:AllNextOffset;
<mvt:if expr="'debug' CIN g.output">
<a href="&mvte:global:next_url;">Next >></a>
&mvte:global:xml;
<mvt:elseif expr="g.continue EQ 'redirect'">
<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:elseif expr="g.continue EQ 'refresh'">
<meta http-equiv="refresh" content="0;URL='&mvt:global:next_url;'" />
<mvt:elseif expr="g.continue EQ 'js'">
<script>window.location = '&mvt:global:next_url;';</script>
</mvt:if>
<mvt:else>
Complete
</mvt:if>
以上是关于xml Miva - 自定义SearchSpring Feed的主要内容,如果未能解决你的问题,请参考以下文章