Skip to content

Data Transformation

The script editor lets you transform imported rows before they are processed. You can edit field values directly in the import workflow using the $row variable.

  • Script input: Write transformation logic against the $row variable for each imported row.
  • Function whitelisting: Only approved PHP functions are available, so you can perform common transformations without exposing the system to unsafe code.
Function GroupFunctions
String Functionsstrlen, strpos, strtolower, strtoupper, trim, substr, str_replace, explode, implode, htmlspecialchars, ucfirst, lcfirst
Hashing Functionsmd5, sha
Array Functionsin_array, count
Math Functionsabs, round, ceil, floor, max, min, rand, sqrt, pow
Date/Time Functionstime, date, strtotime, mktime
Variable Handling Functionsisset, empty
JSON Functionsjson_encode, json_decode
Multibyte String Functionsmb_ereg_replace, mb_ereg_replace_callback, mb_eregi_replace, mb_split, mb_str_pad, mb_str_split, mb_strcut, mb_strimwidth, mb_stripos, mb_stristr, mb_strlen, mb_strpos, mb_strrchr, mb_strrichr, mb_strripos, mb_strrpos, mb_strstr, mb_strtolower, mb_strtoupper, mb_substr, mb_substr_count

You can use data transformation to:

  • remove extra $ symbols from manufacturer values
  • replace spaces or separators in options
  • increase stock values by a fixed amount
  • calculate prices when imported values are empty
  • replace commas with | in keyword fields
  • concatenate meta_title and name

The $row variable is an associative array. Each key represents a column from the imported file, and each value contains the row data for that column.

$manufacturerName = $row['manufacturer_name'];
$row['manufacturer_name'] = str_replace('$', '', $row['manufacturer_name']);
$row['options'] = strtolower($row['options']);
if (isset($row['stock']) && $row['stock'] > 0) {
$row['stock'] += 10;
}
if (isset($row['price_gross']) && $row['price_gross'] == 0) {
$row['price_gross'] = $row['net'] * 1.19;
}

You do not need to return anything manually. Changes to $row are applied during the import process.

$row['manufacturer_name'] = str_replace('$', '', $row['manufacturer_name']);
$row['options'] = str_replace(';', '|', trim($row['options']));
if (isset($row['stock'])) {
$row['stock'] += 10;
}
if (isset($row['price_gross']) && $row['price_gross'] == 0) {
$row['price_gross'] = $row['net'] * 1.19;
}
$row['keywords'] = str_replace(',', '|', $row['keywords']);
$row['meta_title'] = $row['meta_title'] . ' ' . $row['name'];
  • $row is an associative array of imported column values.
  • You can access and modify fields with $row['column_name'].
  • Only whitelisted PHP functions are allowed.
  • All changes are applied directly during the import process.