Accurate Inventory Sync Between Online Store and 1C-Bitrix

Accurate Inventory Sync Between Online Store and 1C-Bitrix ## Incorrect stock levels lead to overselling Overselling occurs when stock data is outdated. Proper 1C-Bitrix inventory management solves this. We've encountered situations where an online store on 1C-Bitrix shows 10 units of an item,

Our competencies:

Frequently Asked Questions

Accurate Inventory Sync Between Online Store and 1C-Bitrix

Incorrect stock levels lead to overselling

Overselling occurs when stock data is outdated. Proper 1C-Bitrix inventory management solves this. We've encountered situations where an online store on 1C-Bitrix shows 10 units of an item, but the physical warehouse is already empty. The customer places an order, we forward it to 1C, and it's rejected. Overselling eats up to 20% of revenue, and losses can exceed $1.8k–2.6k monthly. Standard synchronization via CommerceML runs every 15–60 minutes. That's not enough for high-volume sales: discrepancies accumulate. Our engineers solve this with webhooks and real-time document flow.

What synchronization approaches exist?

Let's compare two main methods:

Method Update frequency Latency Suitable for
CommerceML Scheduled (15-60 min) High Small online stores
Webhooks Real-time Seconds High-volume stores

CommerceML is the standard exchange protocol with 1C, documented in CommerceML. It's reliable but not suitable for scenarios where stock changes quickly. Webhooks update data in 1-2 seconds — 30 times faster than CommerceML. Our experience — over 50 projects with webhooks — shows that payback occurs within six months.

How we implement real-time updates?

To minimize discrepancy — integrate the cash register with Bitrix in real time. Each offline sale immediately triggers a webhook to Bitrix. Implementation steps:

  1. Create a PHP endpoint that accepts JSON from the cash register.
  2. Validate the data and find the product by SKU.
  3. Create a warehouse document of type 'S' (sale) via DocumentTable.
  4. Post the document by calling conduct() — this automatically updates stock in b_catalog_store_product.
  5. Invalidate the product cache.
Webhook implementation example
// /local/ajax/pos-sale-callback.php $data = json_decode(file_get_contents('php://input'), true); foreach ($data['items'] as $item) { $product = \CCatalogProduct::GetByID($item['sku']); if (!$product) continue; // Decrease stock on specific warehouse \Bitrix\Catalog\StoreProductTable::update( ['PRODUCT_ID' => $item['product_id'], 'STORE_ID' => $data['store_id']], ['AMOUNT' => new \Bitrix\Main\DB\SqlExpression('AMOUNT - ?', $item['quantity'])] ); // Recalculate total stock in b_catalog_product \CCatalogProduct::RecalcQuantity($item['product_id']); } 

RecalcQuantity() recalculates b_catalog_product.QUANTITY as the sum across all warehouses in b_catalog_store_product. After that, the product cache must be invalidated — via BXClearCache(false, '/catalog/') or tagged cache. We guarantee update time under 2 seconds.

How to reserve stock for online sales?

A common practice for multi-channel stores: allocate a separate 'online warehouse' in b_catalog_store, whose stock is only for the online store. Physically, goods may be in one warehouse, but logically separated.

Offline sales decrease the 'physical warehouse', while online orders are reserved from the 'online warehouse'. At night, 1C replenishes the online warehouse from the physical one according to a set proportion.

Physical warehouse: 100 units Online quota: 30% = 30 units → stored in b_catalog_store_product (STORE_ID = online_store) Offline quota: 70% = 70 units → not exposed to Bitrix 

This eliminates overselling but reduces available stock for online sales. We tailor the proportion individually based on sales statistics.

How document flow works?

In Bitrix, the catalog module supports warehouse documents: \Bitrix\Catalog\Document\DocumentTable. Document types: A — receipt, S — sale, M — transfer, R — return.

When posting a document via \Bitrix\Catalog\Document\DocumentController::conduct(), stock in b_catalog_store_product is automatically recalculated. This is the correct way to update stock — through documents, not direct UPDATE.

For offline sales: on receiving a webhook from the cash register, we create a document of type S with sale items and post it. This ensures full movement history and accurate inventory accounting.

Inventory reconciliation

Discrepancies between 1C and Bitrix are inevitable. It's crucial to detect them. Once a day we run a reconciliation agent:

// Get stock from 1C via REST API $bx1cItems = get1cQuantities(); // Compare with b_catalog_store_product foreach ($bx1cItems as $sku => $qty) { $bitrixQty = StoreProductTable::getList([ 'filter' => ['PRODUCT.XML_ID' => $sku], 'select' => ['AMOUNT'], ])->fetch()['AMOUNT'] ?? 0; if (abs($bitrixQty - $qty) > 0) { logDiscrepancy($sku, $bitrixQty, $qty); } } 

The discrepancy log allows you to decide: correct Bitrix to match 1C (1C as master) or flag an integration issue. After implementation, the client saves up to $4.5k–6.5k per year by eliminating overselling and manual reconciliation. Annual savings average $2.7k–3.9k.

What's included in the turnkey 1C-Bitrix setup

In each project we provide:

  • Audit of current inventory accounting scheme and integration points
  • Selection of optimal synchronization protocol (CommerceML or webhooks)
  • Endpoint development for cash register and POS terminal webhooks
  • Document flow setup: receipt, sale, transfer, return
  • Implementation of stock reconciliation agent with discrepancy logging
  • Staff training on the updated system
  • Detailed documentation on integration and settings
  • Technical support for one month after launch

Investment starts from $1.4k–1.9k.

Stages and timelines

Stage Duration Result
Analysis 2-3 days Integration scheme, synchronization method selection
Design 3-5 days Technical specification, prototype
Development 5-10 days Webhooks, documents, reconciliation agent
Testing 3-5 days Validation on real data, bug fixing
Launch 1-2 days Deployment, staff training

Timelines — from 2 to 4 weeks. Investment calculated individually based on complexity. Payback — 4–6 months. We are certified 1C-Bitrix specialists with over 10 years of experience. We guarantee that after setup, stock discrepancies will not exceed 0.1% provided stable communication channels.

If you notice stock discrepancies in your store, order an audit and get a synchronization plan. Contact us for a consultation.