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

Miva Knowledge Base
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.
Important Notice: This information is for internal reference only. Use at your own risk.

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

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

mvkb_customfields mvkb_mysql