Add properties to built-in models

You may want to add additional edit form fields to products, configurator pages, questions or answers and display the data in views or process it in various connectors - for this you can add properties to existing models.

Example:

Add a PHP file in {customizationDir}/model_property_customization/ named after a built-in model’s name (e.g. adminproducts.php) and add a function named customPropertyDefinitions[modelName]. It returns KenedoProperty settings arrays, which will be mixed into the built-in model’s properties.

Model to extend

Filename

Function name

Model to extend

Filename

Function name

adminproducts

adminproducts.php

customPropertyDefinitionsAdminProducts()

[modelName]

[modelName].php

customPropertyDefinitions[modelName]()

Example file {customizationDir}/model_property/customization/adminproducts.php:

<?php /** * @return array[] * @see ConfigboxModelAdminproducts::getPropertyDefinitions */ function customPropertyDefinitionsAdminproducts() { $propDefs = array(); ... return $propDefs; }

Now you return KenedoProperty definition arrays to product data and the system will mix them in. Form fields will display in backend forms and KenedoModel’s getRecord() and getRecords() will return the data along with regular product data.

Read about KenedoProperties to see how to work with property definitions.

Note for developers extending question data

The model name for question data is adminelements (legacy reasons).

Useful property settings for adding properties

Store property values in external extension tables

You do not want to add columns to the built-in DB tables, instead you use an extension table and use the KenedoProperty setting ‘storeExternally' and supply the name to the extension table. You create these yourself using Application Update Scripts.

Place the form fields in the desired spot in edit forms

Use property setting positionForm to choose where the property’s form fields shall display. The built-in model’s properties generally use positionForm steps of 10.000 to give ample room to place your form-fields where you need them.

If you need to show properties conditionally

If your form fields should only show under certain conditions (e.g. you add properties to question data and these only pertain to certain question types), then use property setting appliesWhen.

Choose property names with care

To avoid naming collisions in future CB upgrades, best prefix the names of your properties.