<MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.module:code" VALUE = "Sample">
<MvASSIGN NAME = "l.module:name" VALUE = "Sample Module">
<MvASSIGN NAME = "l.module:provider" VALUE = "Miva">
<MvASSIGN NAME = "l.module:version" VALUE = "9.0000">
<MvASSIGN NAME = "l.module:api_ver" VALUE = "5.72">
<MvASSIGN NAME = "l.module:features" VALUE = "json">
<MvASSIGN NAME = "l.module:description" VALUE = "Example Module">
</MvFUNCTION>
<MvCOMMENT> json
Sample Request: http://support-test-01.merchant.local/mm5/json.mvc?Store_Code=95&Function=Module&Module_Code=Sample&Session_Type=admin&Module_Function=Export_Products&Username=administrator&Password=P@ssw0rd
</MvCOMMENT>
<MvFUNCTION NAME="Module_JSON" PARAMETERS="module var" STANDARDOUTPUTLEVEL="">
<MvIf EXPR="g.Module_Function EQ 'Export_Products'">
<MvASSIGN NAME="l.ol" VALUE="{ miva_output_header( 'Content-Type', 'text/xml' ) }" >
<MvCOMMENT>Load All Products</MvCOMMENT>
<MvIF EXPR="{ NOT [ g.Module_Library_DB ].ProductList_Load_All( l.products ) }">
<MvFUNCTIONRETURN VALUE = 0 >
</MvIF>
<MvCOMMENT>Add Retail Price to Structure</MvCOMMENT>
<MvASSIGN NAME = "g.product_count" VALUE ="{ miva_array_elements( l.products ) }">
<MvASSIGN NAME= "g.counter" value="1">
<MvWHILE EXPR = "{ g.counter LE g.product_count }">
<MvASSIGN NAME = "l.products" INDEX= "{ g.counter }" MEMBER="retail_price" VALUE ="{ l.products[ g.counter ]:price }">
<MvASSIGN NAME= "g.counter" value="{ g.counter + 1 }">
</MvWHILE>
<MvCOMMENT>Load Discountd Prices. This function replaces the price/formatted_price with the sale price</MvCOMMENT>
<MvIF EXPR="{ NOT [ g.module_feature_tui_ut ].CommonComponentFields_Initialize_Product_Discounts_Runtime( l.products, g.product_count ) }">
<MvFUNCTIONRETURN VALUE = 0 >
</MvIF>
<MvEVAL EXPR="<Products>" >
<MvFOREACH ARRAY = "l.products" ITERATOR = "l.product" >
<MvEVAL EXPR="<Product>" >
<MvEVAL EXPR="{ '<name>' $ l.product:name $ '</name>' $ asciichar(10) $ asciichar(10) }">
<MvEVAL EXPR="{ '<code>' $ l.product:code $ '</code>' $ asciichar(10) $ asciichar(10) }">
<MvEVAL EXPR="{ '<retail_price>' $ l.product:retail_price $ '</retail_price>' $ asciichar(10) $ asciichar(10) }">
<MvEVAL EXPR="{ '<sale_price>' $ l.product:price $ '</sale_price>' $ asciichar(10) $ asciichar(10) }">
<MvEVAL EXPR="{ '<savings>' $ l.product:discounts[1]:discount $ '</savings>' $ asciichar(10) $ asciichar(10) }">
<MvEVAL EXPR="</Product>" >
</MvFOREACH>
<MvEVAL EXPR="</Products>" >
</MvIF>
<MvFUNCTIONRETURN VALUE = 1 >
</MvFUNCTION>