Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

You can add properties to the products, pages, questions and answers. Also to product lists and customer groups.

To do this you need the following things:

  • Add a model property customization file, essentially a file with a function that returns additional property definitions (see KenedoModel → Properties)

  • Create an extension DB-table with the columns holding the extended data

Example:

Say you mean to add a yes/no property to the product data. The model that handles data for products is called ‘adminproducts’, the class file is in {appDir}/models/adminproducts.php.

Add a Model Property Customization File:

Create the file {customizationDir}/model_property_customization/adminproducts.php and add the function customPropertyDefinitionsAdminproducts() in it.

function customPropertyDefinitionsAdminproducts() {
  $propDefs = array();
  
  $propDefs['is_new'] = array(
		'name'=>'is_new',
		'label'=>'Label of the property',
		'tooltip'=>'Tooltip content describing the property to the user.',
		'type'=>'boolean',
		'default'=>'0',

		'storeExternally'=> true,
		'foreignTableName'=>'#__configbox_external_product_appends',
		'foreignTableAlias'=>'product_appends',
		'foreignTableKey'=>'product_id',

		'positionForm'=>40100,
	);
	
	return $propDefs;	
	
}

The framework will automatically search for the file and function and use the property definitions.

Learn about the property’s settings in that article. In this article we focus on the property settings that are needed for overriding.

See these lines from the property’s settings:

'storeExternally'=> true,
'foreignTableName'=>'#__configbox_external_product_appends',
'foreignTableAlias'=>'product_appends',
'foreignTableKey'=>'product_id',

This instructs the framework to

  1. Store the property’s values in a separate extension table (storeExternally)

  2. In which table it shall store the values (foreignTableName)

  3. How to join the extension table (foreignTableKey)

Create an extension DB-table

Based on the property definition settings above, we’d create the following MySQL table:

#__configbox_external_product_appends

Column name

Type

Notes

product_id

INT UNSIGNED PRIMARY KEY

This relates to your ‘foreignTableKey’. The column should be the table’s primary key

is_new

TINYINT UNSIGNED

The column for the property ‘is_new’

For creating the DB (see Application Update Script)

  • No labels