We build, you explore: a new support experience is on the way...
Take a sneak preview of our new knowledge base now!
We would like to add a calculated* column which indicates the volume of the product in cubic metres (m³).
We will then be able to:
To add the field to the list of available fields for your products grids, click on the
in the 'Add a field' panel and enter the following information:
What is the field ID?: v_m3
Sc creates the field, you now need to populate the grid with:
Field name: Volume in m3
Table: Another table
Type: Just display
Refresh combinations: No
The formula for calculating this field is as follows: Width x Height x Depth / 1000000
For a calculated field, we have two options:
SQL: the field can be used on all product grids
PHP: the field can only be used if the necessary fields (Width, Height, Depth for our example) are present in the grid.
SQL: From the Advanced Properties panel on the right handside, select the menu SQL Select and enter:
return ' , ((p.`width`*p.`height`*p.`depth`)/1000000) as v_m3';
PHP: From the Advanced Properties panel on the right handside, select the menu PHP Get Row data and enter:
if($col == 'v_m3'){
$prodrow[$col] = (float)((float)$prodrow['width']*(float)$prodrow['height']*(float)$prodrow['depth'])/1000000;
}
Please note the $prodrow variable contains all the fields of the grid with their final value.
Save on the toolbar ![]()
Exit the editing window.
The new field is now present in the list of available fields and you can add it to your product grids.
* calculated for display. Is not stored in database.