To create a support ticket, start a search

Products Grid: Adding a column 'nb of combinations'


We would like to add a column displaying the number of combinations per product.


To add the field to the list of available fields for your grids, click on the in the 'Add a field' panel and enter the following information:

What is the field ID?: nb_combinations


Sc creates the field, you now need to populate the grid with:

Field name: Nb combinations
Table: Another table
Type: only display


From the Advanced Properties panel on the right handside:

- select the menu PHP Get Row Data and enter:

if ($col == "nb_combinations") {
$value = Db::getInstance()->getValue("SELECT IF(COUNT(*)>0, COUNT(id_product_attribute), 0) FROM " . _DB_PREFIX_ . "product_attribute WHERE id_product=" . (int)$prodrow['id_product']);
$prodrow['nb_combinations'] = (int)$value;


Related articles