Setting up field mapping during parsing for 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

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.