To create a support ticket, start a search

Products Grid: Adding a field added to ps_product table by the installation of a 3rd party module


Prerequisites

The field needs to exist in your database (normally created during the module's installation)

 

Target

We would like to add the field 'Logistician' of the 'Logisticians management module' allowing the selection of logistician in the products grid.

We will then be able to:

- use the filters in the grids to optimize the selection of products
- mass-edit this field using Store Commander's copy/paste option 
- rapidly export the products grid with this field

 

Setup

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

What is the field ID?: id_logistician (should be exactly the name as it is in the database).

 

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

Field name: Logistician
Table: product
Type: Multiple choices
Refresh combinations: No

 

From the Advanced Properties panel on the right handside:

- select the menu Select options and enter:

$sql = 'SELECT id_logistician,name_logistician FROM '._DB_PREFIX.'logistician ORDER BY name_logistician';

$res = Db::getInstance()->ExecuteS($sql);
$tmp = array(0 => 'NA');
foreach ($res AS $row) {
    $tmp[$row['id_logistician']] = $row['name_logistician'];
}
return $tmp;

 

Adapt this code to your specific needs.

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.