Setting up the export of balances from 1C to 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
    1173
  • 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
    745
  • 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

Setting up product quantity export from 1C to 1C-Bitrix

Product quantities — part of standard CommerceML exchange. Transmitted in offers.xml file as element <Количество> for each SKU. But in most projects, standard exchange is insufficient: need more frequent synchronization, split by warehouses or partial update without full catalog export.

How quantities enter Bitrix

In standard exchange, quantity is written to field QUANTITY in table b_catalog_product. Value is linked to SKU via PRODUCT_ID = b_iblock_element.ID.

If 1C is configured with warehouse, quantities are transmitted split by warehouse. In Bitrix warehouses are — module catalog with table b_catalog_store and b_catalog_store_product. For displaying "available in store X", need to use warehouse accounting.

Separate quantity synchronization

Standard exchange exports entire catalog — with many goods can take minutes. For frequent updates (every 5–15 minutes), use separate mechanism:

Option 1: separate XML file. 1C forms lightweight XML only with quantities (without descriptions and pictures) and sends to separate endpoint. On Bitrix side — custom handler, reads XML and updates b_catalog_product.QUANTITY.

Option 2: REST API / HTTP handler. 1C sends POST with JSON or POST-parameters: sku → quantity. Handler on Bitrix side accepts, validates, updates quantities. Faster than XML parsing, simpler to debug.

Option 3: via 1C as initiator + Bitrix agent. 1C writes quantities to intermediate table (or file on server). Bitrix agent every N minutes reads intermediate data and updates catalog. Suitable if direct HTTP from 1C is difficult.

Updating quantity in Bitrix

// Find PRODUCT_ID by XML_ID
$element = CIBlockElement::GetList(
    [],
    ['XML_ID' => $xmlId, 'IBLOCK_ID' => OFFERS_IBLOCK_ID],
    false,
    ['nTopCount' => 1],
    ['ID']
)->Fetch();

if ($element) {
    CCatalogProduct::Update($element['ID'], ['QUANTITY' => $newQuantity]);
}

With many goods (thousands) direct update via loop is slow — better use batch UPDATE via $DB->Query() or \Bitrix\Main\Application::getConnection()->query().

Warehouse accounting

If shop has several warehouses, enable warehouse accounting: Catalog → Warehouses. Table b_catalog_store_product stores quantities per warehouse for each good. Update:

\Bitrix\Catalog\StoreProductTable::update(
    ['PRODUCT_ID' => $productId, 'STORE_ID' => $storeId],
    ['AMOUNT' => $newAmount]
);

With warehouse accounting enabled, b_catalog_product.QUANTITY becomes aggregated (sum across warehouses) and updates automatically.

Common mistakes

  • Quantity goes to 0 on every full exchange — 1C not transmitting quantities in offers.xml. Need to enable quantity export in 1C exchange settings.
  • Quantities update, but product shows "out of stock" on site — check component logic: possibly not QUANTITY used, but custom property "In Stock".
  • Negative quantities — 1C allows going negative. In Bitrix handler limit: max(0, $quantity).