To create a support ticket, start a search

Combinations Grid: Add a field from a table outside the products table

Prerequisites:

- Store Commander version 2014-03-12
- SC Grids Editor Pro Add-on - version 1.0
- The field needs to exist in your database

 

Target:

We would like to add the field 'BIO Label' which will allow to differentiate this type of products in the grids.

For this example, this field is located in ps_label table  id_product_attribute ; label_bio (0/1) ).

We will then be able to:

- use the filters in the grids to optimize the selection of combinations
- mass-edit this field using Store Commander's copy/paste option
- rapidly export the combinations 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?:  label_bio (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: BIO Label

Table: special

Type: multiple choice

 

  • From the Advanced Properties panel:

SQL Select:

return ' ,lab.label_bio ';

SQL Left join:

return ' LEFT JOIN '._DB_PREFIX_.'label lab ON (lab.id_product_attribute = pa.id_product_attribute) ';

 PHP definition:

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

 PHP onAfterUpdateSQL:

 $sql = "UPDATE "._DB_PREFIX_."label SET label_bio = ".(int)Tools::getValue('label_bio',0)." WHERE id_product_attribute=".int()$id_product_attribute;

Db::getInstance()->Execute($sql);

 

  • If you wish to add a yes/no choice, from the advanced properties panel:

List of choices:

return array(1=>_l('Yes') , 0=>_l('No')); 

 

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

Select the combinations grid

Drag/drop the field in this grid

To use the list of choice, select 'Type: multiple choice (Type A) for this field