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.
Note: Be sure to use a positionForm value that does not yet exist. Have a look at the base table’s property definitions to see the positionForm values in each in order to pick the position you like the property to show up in.
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
Store the property’s values in a separate extension table (storeExternally)
In which table it shall store the values (foreignTableName)
How to join the extension table (foreignTableKey)
Create an extension DB-table
Based on the property definition settings above, we create the following MySQL table:
#__configbox_external_product_appends
As per convention, custom tables are prefixed as ‘external' in general, extension tables use the base table’s name followed by the word ‘appends’.
Column name | Type | Notes |
---|---|---|
product_id | INT UNSIGNED PRIMARY KEY | This relates to your ‘foreignTableKey’. It’s recommended to make it a primary key column and of same type as the primary key of the base table. On top of that set a foreign key constraint with ON DELETE CASCADE, ON UPDATE CASCADE. |
is_new | TINYINT UNSIGNED | The column for the property ‘is_new’ |
For creating the extension table in an organized way, see Application Update Script.
Test the outcome
For troubleshooting, have a look at the configbox_errors log file for model configuration issues. configbox_upgrade_errors for any DB schema change problems.