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 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).
Field name: BIO Label
Table: special
Type: multiple choice
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 :
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);
}
List of choices:
return array(1=>_l('Yes'), 0=>_l('No'));
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