Skip to content

Instantly share code, notes, and snippets.

@tessguefen
Created Oct 8, 2015
Embed
What would you like to do?
MvDo variant v=? thing
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_ID( l.parts[1]:product_id, l.settings:master_product )" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.settings:product:product_url" value="Store_Product_URL(l.settings:master_product, NULL)" />
<mvt:assign name="l.settings:product:product_url" value="l.settings:product:product_url $ '?v=' $ l.parts[1]:variant_id " />
<mvt:comment>
CUSTOM Pre-Load Variant based off Passed Variant ID
</mvt:comment>
<mvt:if expr="NOT ISNULL g.v">
<mvt:item name="ry_toolbelt" param="assign|g.sql|'SELECT attr_id, attmpat_id, option_id FROM s01_ProductVariants WHERE variant_id = `' $ MySqlEscape(g.v) $ '` AND product_id = `' $ MySqlEscape(l.all_settings:product:id) $ '`'" />
<mvt:item name="ry_toolbelt" param="query|g.sql|variant_attributes" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="AttributeList_Load_Product(l.settings:product:id, l.settings:loaded_attributes)" />
<mvt:foreach iterator="loaded_attribute" array="loaded_attributes">
<mvt:foreach iterator="variant_attribute" array="variant_attributes">
<mvt:if expr="l.settings:loaded_attribute:id EQ l.settings:variant_attribute:attr_id">
<mvt:if expr="l.settings:variant_attribute:attmpat_id GT 0">
<mvt:do file="g.Module_Feature_ATT_DB" name="l.success" value="AttributeTemplateOption_Load_ID(l.settings:variant_attribute:option_id, l.option)" />
<mvt:else>
<mvt:do file="g.Module_Library_DB" name="l.success" value="Option_Load_ID(l.settings:variant_attribute:option_id, l.option)" />
</mvt:if>
<mvt:assign name="l.settings:tmp:value" value="l.option:code" />
<mvt:assign name="l.count" value="miva_array_insert_var( g.Product_Attributes, l.settings:tmp, l.pos1 )" />
</mvt:if>
</mvt:foreach>
</mvt:foreach>
</mvt:if>
<mvt:comment>
CUSTOM Check if Product is Variant
| If Variant redirect to Master w/ a passed Variant ID
</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantPartList_Load_Part( l.settings:product:id, l.parts )" />
<mvt:if expr="miva_array_elements( l.parts ) GT 0">
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_ID( l.parts[1]:product_id, l.settings:master_product )" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.settings:master_product:uri" value="Store_Product_URL(l.settings:master_product, NULL)" />
<mvt:assign name="l.null" value="miva_output_header( 'Location', l.settings:master_product:uri $ '?v=' $ l.parts[1]:variant_id )" />
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment