xml 生成自定义变体URL(Acme)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 生成自定义变体URL(Acme)相关的知识,希望对你有一定的参考价值。

<mvt:comment>
	GLOBAL Setup
	| 1) File Settings
	| 2) Initial File Handling
	|	- Set Offset / Per Page Variables
	|	- Delete Existing File (if EXISTS)
	| 3) Special Character Reference Variables
	========================================
</mvt:comment>
<mvt:comment> =1 File Settings </mvt:comment>
<mvt:assign name="g.File_Path" value="'/variant-links/'" />
<mvt:assign name="g.File_Name" value="'variant-links.csv'" />

<mvt:comment> =2 Initial File Handling </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 AND g.debug NE 1">
	<mvt:assign name="l.empty" value="''" />
	<mvt:assign name="l.file_exists" value="sexists( g.File_Path $ g.File_Name )" />
	<mvt:if expr="l.file_exists EQ 1">
		<mvt:assign name="l.file_deleted" value="sdelete( g.File_Path $ g.File_Name )" />
		<mvt:if expr="l.file_deleted EQ 1">
			<mvt:assign name="l.file_created" value="file_create( g.File_Path $ g.File_Name, 'SCRIPT', l.empty )" />
		</mvt:if>
	<mvt:else>
		<mvt:assign name="l.file_created" value="file_create( g.File_Path $ g.File_Name, 'SCRIPT', l.empty )" />
	</mvt:if>
</mvt:if>

<mvt:comment> =3 Special Character Reference Variables </mvt:comment>
<mvt:assign name="l.delimiter" value="asciichar( 44 )" />
<mvt:assign name="l.break" value="asciichar( 10 )" />
<mvt:assign name="l.double_quote" value="asciichar( 34 )" />
<mvt:assign name="l.tab" value="asciichar( 9 )" />

<mvt:comment>================================================================================</mvt:comment>

<mvt:comment>
	Header Row
	| 1) Define the CSV Header Fields
	| 2) Write Header Row to File
	|	- Check if First Offset ... Write Header Row
	========================================
</mvt:comment>
<mvt:comment> =1 Define the CSV Header Fields </mvt:comment>
<mvt:assign name="g.Header_Row" value="
	'MASTER_PRODUCT_CODE' $ l.delimiter $
	'MASTER_PRODUCT_SKU' $ l.delimiter $
	'MASTER_PRODUCT_NAME' $ l.delimiter $
	'VARIANT_PRODUCT_CODE' $ l.delimiter $
	'VARIANT_PRODUCT_SKU' $ l.delimiter $
	'VARIANT_PRODUCT_NAME' $ l.delimiter $
	'VARIANT_URL'
" />
<mvt:assign name="g.Header_Row" value="g.Header_Row $ l.break" />

<mvt:comment> =2 Write `g.Header_Row` to File </mvt:comment>
<mvt:if expr="g.AllOffset LT g.Per_Page AND g.debug NE 1">
	<mvt:assign name="l.write_line" value="file_append( g.File_Path $ g.File_Name, 'SCRIPT', g.Header_Row )" />
</mvt:if>

<mvt:comment>================================================================================</mvt:comment>

<mvt:comment>
	All Products
	========================================
</mvt:comment>
<mvt:foreach iterator="product" array="all_products:products">
	
	<mvt:comment>
		Reset Key Variables
		| Null-out variables for the next Iteration
		========================================
	</mvt:comment>
	<mvt:assign name="g.sql" value="NULL" />
	<mvt:assign name="l.settings:variant_id_numbers" value="NULL" />
	
	<mvt:comment> Check if (Master)Product Has Variants </mvt:comment>
	<mvt:item name="ry_toolbelt" param="assign|g.sql|'SELECT DISTINCT(variant_id) FROM s01_ProductVariants WHERE product_id = `' $ MySqlEscape(l.all_settings:product:id) $ '`'" />
	<mvt:item name="ry_toolbelt" param="query|g.sql|variant_id_numbers" />

	<mvt:if expr="miva_array_elements( l.settings:variant_id_numbers ) GT 0">

		<strong>&mvt:product:name;</strong>
		<ul>
		
		<mvt:comment> Loop Through Variant IDs </mvt:comment>
		<mvt:foreach iterator="variant_id" array="variant_id_numbers">

			<mvt:comment>
				Reset Key Variables
				| Null-out variables for the next Iteration
				========================================
			</mvt:comment>
			<mvt:assign name="g.Row" value="NULL" />
			<mvt:assign name="l.variant" value="NULL" />
			
			<mvt:comment> Load Variant Product </mvt:comment>
			<mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Variant( l.settings:product:id, l.settings:variant_id, l.variant )" />
			<mvt:if expr="l.success EQ 1">

				<mvt:comment> Generate Variant URL </mvt:comment>
				<mvt:do file="g.Module_Feature_URI_UT" name="l.settings:product:variant_url" value="Store_Product_URL( l.settings:product, NULL )" />
				<mvt:assign name="l.settings:product:variant_url" value=" l.settings:product:variant_url $ '?v=' $ l.settings:variant_id " />
				
				<mvt:comment>
					Output Product Variables
					========================================
				</mvt:comment>
				<mvt:assign name="g.Row" value="
					l.double_quote $ l.settings:product:code $ l.double_quote $ l.delimiter $
					l.double_quote $ l.settings:product:sku $ l.double_quote $ l.delimiter $
					l.double_quote $ l.settings:product:name $ l.double_quote $ l.delimiter $
					l.double_quote $ l.variant[1]:code $ l.double_quote $ l.delimiter $
					l.double_quote $ l.variant[1]:sku $ l.double_quote $ l.delimiter $
					l.double_quote $ l.variant[1]:name $ l.double_quote $ l.delimiter $
					l.double_quote $ l.settings:product:variant_url $ l.double_quote
				" />
				<mvt:assign name="g.Row" value="g.Row $ l.break" />

				<li>&mvt:product:variant_url;</li>
				
				<mvt:comment> Write Line to File </mvt:comment>
				<mvt:if expr="g.debug NE 1">
					<mvt:assign name="l.write_line" value="file_append( g.File_Path $ g.File_Name, 'script', g.Row )" />
				</mvt:if>
			</mvt:if>

		</mvt:foreach>

		</ul>

	</mvt:if>

	

</mvt:foreach>

<mvt:comment>================================================================================</mvt:comment>

<hr>
<mvt:if expr="g.AllNextOffset GT 0">
	<mvt:assign name="g.next" value="l.settings:urls:_self:auto_sep $ 'AllOffset=' $ g.AllNextOffset $ '&continue=' $ g.continue" />	
	<mvt:if expr="g.continue EQ 1">
		<meta http-equiv="refresh" content="0; URL='&mvt:global:next;'" />
	</mvt:if>
	<a href="&mvt:global:previous;">PREV</a> &mvt:global:AllNextOffset; <a href="&mvt:global:next;">NEXT</a>
<mvt:else>
	Complete
	<mvt:assign name="l.null" value="miva_output_header( 'Location', 'http://' $ g.domain:name $ g.File_Path $ g.File_Name )" />
</mvt:if>

以上是关于xml 生成自定义变体URL(Acme)的主要内容,如果未能解决你的问题,请参考以下文章

xml 具有变体的自定义数据馈送

如何使用带有自定义主题变体的 vuetify 颜色道具

在 Joomla 3 中向组件添加带有自定义 url 参数的菜单类型

如何压缩和解压缩 URL C++ 中的 xml

如何在自定义变体上捕获数组索引

如何在 tailwindcss 中创建自定义变体?