To create a support ticket, start a search

Product Import: Importing a field in product table


Prerequisites

The field has to be present in the database

 

Target

We would like to import a field in product table.

 

Setup

To add the field to the list of available fields to import, click on the add_dis.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 on the right handside:

- select the menu Import Combinations Process and enter:

if ($switchObject == 'my_field') {
    $value = $GLOBALS['import_value'];
    $id_prd = (!empty($id_product) ? (int)$id_product : (int)$newprod->id);
    if (!empty($id_prd)) {
        $sql = "UPDATE " . _DB_PREFIX_ . "product SET `" . $switchObject . "`='" . psql($value) . "' WHERE id_product=" . (int)$id_prd;
	Db::getInstance()->Execute($sql);
    }
}

 

You will need to adapt this code to your needs.

 

Exit the editing window.

The new field can now be included in your import mapping.

 




Related articles