To create a support ticket, start a search

Combinations Grid: Adding a column 'nb of sales in the last month'


- Store Commander version 2014-03-12
- SC Grids Editor Pro Add-on - version 1.0



We would like to add a column displaying the number of sales for the last month in the combinations panel.

We will then be able to:

- use filters in the grids to find the most sold products and eventually delist unsold products

- export quickly the products grid including this field to work on an Excel spreadsheet



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

What is the field ID?: nb_sale_1_month


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

Field name: Nb sales for the last month

Table: enter: special

Refresh combinations: keep 'yes'

Type: just displayed


  • From the Advanced Properties panel:


SQLSelectDataSelect :

return ',(SELECT SUM(od.product_quantity) AS nb_opq
            FROM `'._DB_PREFIX_.'order_detail` od
            INNER JOIN `'._DB_PREFIX_.'orders` o ON (od.id_order = o.id_order)
            WHERE od.product_attribute_id=pa.id_product_attribute
            AND o.valid=1
            AND o.current_state IN (4,5)
            AND o.date_add >= (SELECT DATE_ADD("'.date("Y-m-d").' 00:00:00", INTERVAL -1 MONTH))
            LIMIT 1) AS nb_sale_1_month';


           Php Definition :

$combArray[$combinaison['id_product_attribute']]['nb_sale_1_month'] = $combinaison['nb_sale_1_month'];


Here we look for valid orders with a status 4 or 5 (refer to Prestashop > Orders > Status) with a date of at least one month. You then duplicate this field and modify the line before last with INTERVAL -3MONTH)) to get the number of sales for the past 3 months.


  • Exit the editing window and add the field to your grids