Field Mapping Configuration for Parsing in 1C-Bitrix
The parser has extracted data — now you need to determine which Bitrix field each source attribute maps to. This is field mapping. Hardcoding the mapping in PHP is a poor approach: any change to the source structure or addition of a new field requires a code change and deployment. The right approach is a configurable mapping stored in the database and editable through an admin interface.
What Mapping Is and What It Contains
Mapping is a correspondence table between source attributes and Bitrix fields/properties:
| Source field | Bitrix field type | Bitrix code | Transformation |
|---|---|---|---|
product_name |
Element field | NAME |
trim |
sku |
Element field | XML_ID |
as-is |
price |
Price type | 1 (retail) |
float, round 2 |
quantity |
Catalog field | CATALOG_QUANTITY |
int |
color |
Property (list) | COLOR |
lookup enum |
weight_g |
Property (number) | WEIGHT |
/ 1000 (g→kg) |
description_html |
Element field | DETAIL_TEXT |
HTMLPurifier |
category_id |
Section | IBLOCK_SECTION_ID |
section_map |
Mapping Storage Schema
Highload block ParserFieldMapping with fields:
UF_PARSER_ID — parser/source ID (linked to the parsers table)
UF_SOURCE_FIELD — field name in the source (string)
UF_TARGET_TYPE — target type: field|property|price|stock|section
UF_TARGET_CODE — field or property code in Bitrix
UF_TRANSFORM — transformation (JSON: {"type": "divide", "by": 1000})
UF_ACTIVE — active flag
UF_SORT — application order
Alternative — a JSON config file or a PostgreSQL table if you use a native database.
Transformation Types
Basic:
-
as-is— no change -
trim— strip whitespace -
int/float— type cast -
boolean— "in stock", "yes", "1" → true
Mathematical:
-
multiply/divide— unit conversion -
add_markup— multiply by a markup coefficient
Text:
-
strip_html— remove tags -
purify_html— HTMLPurifier with allowed tags -
transliterate— for generating CODE
Value mapping (lookup):
-
enum_map— correspondence table "source value → Bitrix enum ID" -
section_map— correspondence table "source category ID → Bitrix section ID"
Admin Interface
The mapping UI in the admin panel is the key element — without it everything else loses its purpose. Minimum requirements:
- List of source fields (auto-detected on a test parser run)
- Dropdown to select the Bitrix target field
- Form for configuring the transformation
- "Test" button — runs one test object through the mapping and shows the result
Applying the Mapping in Code
class FieldMapper {
public function map(array $sourceData, int $parserId): array {
$mappings = $this->getMappings($parserId); // from the database
$result = ['fields' => [], 'properties' => [], 'price' => null, 'stock' => null];
foreach ($mappings as $mapping) {
$rawValue = $sourceData[$mapping['source_field']] ?? null;
if ($rawValue === null) continue;
$value = $this->transform($rawValue, $mapping['transform']);
match($mapping['target_type']) {
'field' => $result['fields'][$mapping['target_code']] = $value,
'property' => $result['properties'][$mapping['target_code']] = $value,
'price' => $result['price'][$mapping['target_code']] = $value,
'stock' => $result['stock'] = $value,
'section' => $result['fields']['IBLOCK_SECTION_ID'] = $this->mapSection($value),
};
}
return $result;
}
}
Project Timeline
| Phase | Duration |
|---|---|
| Mapping storage schema design | 4–6 hours |
| Transformation layer development | 4–8 hours |
| Admin interface for editing | 1–2 days |
| Integration with existing parsers | 4–8 hours |
Total: 3–5 working days. An investment that pays off when working with three or more data sources.







