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:
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?: 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: Another table
Type: multiple choices
From the Advanced Properties panel on the right handside:
- select the menu SQLSelect and enter:
return ' ,lab.label_bio';
- select the menu SQL Left Join and enter:
return ' LEFT JOIN '._DB_PREFIX_.'label lab ON (lab.id_product_attribute = pa.id_product_attribute) ';
- select the menu PHP definition and enter:
$combArray[$combinaison['id_product_attribute']]['label_bio'] = $combinaison['label_bio'];
- select the menu PHP onAfterUpdateSQL and enter:
if (isset($_POST['label_bio'])){
$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);
}
- to add a yes/no choice, select the menu List of choices and enter:
return array(1=>_l('Yes'), 0=>_l('No'));
Exit the editing window.
The new field is now present in the list of available fields and you can add it to your combination grid.
To use the list of choice, select 'Type: multiple choice (Type A) for this field.