Import Binding The Unique Field “Code”
The following examples refers to the code present next to each entity field
Here you can use the $value variable to get the current column’s value.
The following example shows the PHP code for binding the “CODE” field with no spaces at the beginning or at the end of the string.
This is a very important safety check for key fields and we suggest to perform this check every time you want to import a key field or a calculated key field.
/* $value contains the value of the current column in the import file, calling trim() method (after casting as string type) to eliminate any space at the beginning or at the end of the string */ $value = trim((string)$value); /* after spaces were removed, the 'CODE' present in the import file is saved in the cust_code field of the current model */ $model->setCustCode($value);