To create a support ticket, start a search

Product Import: importing a product combination

Prerequisites

  • Store Commander version 2015-07-01
  • SC Grids Editor Pro Add-on - version 1.2
  • The field has to be present in the database, in ps_product and ps_product_attribute tables

 

Target

We would like to import information (numerical value) onto a product from a CSV file.

If the product does not use combinations, ps_product field will be updated.

If the product uses combinations, the value on the base product will be set to 0 and the corresponding combination will be updated.

 

Setup

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

 

What is the field ID?: my_field (has to correspond exactly to the field name in the table)

 

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

ID: my_field

Name: my_field

 

  • From the Advanced Properties panel (right hanside) > Import Process, add the following

 

if ($switchObject=='my_field' && $GLOBALS['import_value']!='')
{
$TODO[]="UPDATE "._DB_PREFIX_."product SET my_field='".importConv2Float($GLOBALS['import_value'])."' WHERE id_product=".intval($id_product)."";
}

 

  • From the Advanced Properties panel (right hanside) > Import Process for combinations, add the following

 

if ($switchObject=='my_field' && isCombinationWithID() && $GLOBALS['import_value']!='')
{
$TODO[]="UPDATE "._DB_PREFIX_."product SET my_field=0 WHERE id_product=".intval($id_product);
$TODO[]="UPDATE "._DB_PREFIX_."product_attribute SET my_field='".importConv2Float($GLOBALS['import_value'])."' WHERE id_product_attribute=".intval($id_product_attribute);
}

 

You will need to adapt this code to your needs.

 

  • Exit the editing window and you can use the field in your import mapping