Miva Merchant Development by Scot's Scripts

CUSTOM FIELDS: Custom Function to Load All Fields for Store Item

Miva Random Code Trivia

Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.

WARNING:

This information is offered "AS IS" for internal reference only. Use at your own risk.
Does AI actually understand your Miva Merchant store? Our smart JSON-LD schema generator makes sure it does. Contact us to get started. (more info)
SEO Audit & Inquiries • News & Updates • SEO for Miva Merchant

CUSTOM FIELDS: Custom Function to Load All Fields for Store Item

THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED;
THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.

Scot Ranney • December 19, 2023


Load Custom Fields For Something

This custom function will load all fields and values for Products.

CFM_ProdValues can be changed to CFM_CatValues, CFM_CustValues, CFM_OrderValues, and CFM_PageValues (custom fields for pages, ie, SEO tab)

<MvFUNCTION NAME = "customfield_list_load" PARAMETERS = "offset,eof var,offset,field_id,value" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "">
	<MvOPENVIEW NAME	= "Merchant"
	VIEW	= "ProductFieldValues"
	QUERY	= "{ 
		'SELECT * FROM ' $ g.Store_Table_Prefix $ 'CFM_ProdValues 
		WHERE FIELD_ID = ? AND VALUE = ? 
		LIMIT ' $ l.offset $ ' OFFSET ' $ l.offset }"
	FIELDS = "l.field_id, l.value">
	<MvWHILE EXPR = "{ NOT ProductFieldValues.d.EOF }">
		<MvASSIGN NAME = "l.info:field_id" VALUE = "{ ProductFieldValues.d.field_id }" />
		<MvASSIGN NAME = "l.info:product_id" VALUE = "{ ProductFieldValues.d.product_id }" />
		<MvASSIGN NAME = "l.info:value" VALUE = "{ ProductFieldValues.d.value }" />
		<MvASSIGN NAME = "l.info:value_long" VALUE = "{ ProductFieldValues.d.value_long }" />
		<MvASSIGN NAME = "l.return" INDEX="{ ++l.pos }" VALUE = "{ l.info }" />
		<MvSKIP NAME = "Merchant" VIEW = "ProductFieldValues">
	</MvWHILE>
	<MvIF EXPR = "{ productfieldvalues.d.eof }">
		<MvASSIGN NAME = "l.eof" VALUE = "{ 1 }" />
	</MvIF>
	<MvCLOSEVIEW NAME = "Merchant" VIEW = "ProductFieldValues">
	<MvFUNCTIONRETURN VALUE = "{ l.return }">
</MvFUNCTION>

https://www.scotsscripts.com/mvblog/custom-fields-custom-function-to-load-all-fields-for-store-item.html

customfields mysql