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
QUANTITYused, but custom property "In Stock". -
Negative quantities — 1C allows going negative. In Bitrix handler limit:
max(0, $quantity).







