Parsing Product Stock Levels from Supplier Websites for 1C-Bitrix
The situation: the supplier provides no API, sends price lists once a week by email, and actual stock levels change daily. A customer places an order — the item is out of stock. The solution is to parse the supplier's storefront and update the CATALOG_QUANTITY field in 1C-Bitrix.
What exactly to parse
Stock levels on a supplier's website can be represented in different ways:
- Numeric value ("in stock: 47 pcs") — parse the number directly
- Availability status ("in stock" / "on order" / "out of stock") — map to 0/1/999
- Multiple warehouses — sum them up or take the nearest warehouse
Sometimes stock levels are embedded in JS variables on the page (window.__PRODUCT_DATA__ = {...}) — locate them via regex in the page body; this is faster than a headless browser.
Linking your catalog products to supplier items
This is the key step. Without reliable mapping, parsing is useless. Options:
Supplier SKU — add a SUPPLIER_SKU property to the infoblock. During parsing, find the element with that value via CIBlockElement::GetList() filtered by the property.
XML_ID — if products were previously imported from the supplier's price list, the XML_ID may match their internal ID.
EAN/barcode — a universal option for branded products.
For large catalogs (10,000+ SKUs), filtering by property through the ORM is slow. It is better to build a reverse mapping supplier_sku → element_id in Redis or a custom table and update it whenever the catalog changes.
Updating stock levels in 1C-Bitrix
Update via CCatalogProduct::Update():
CCatalogProduct::Update($elementId, [
'QUANTITY' => $parsedQty,
'QUANTITY_RESERVED' => 0,
]);
If the store uses warehouses (b_catalog_store), update via CCatalogStoreProduct::Update() specifying STORE_ID.
Important: when updating only the quantity, do not touch ACTIVE — otherwise you will lose manual activity edits. Make a separate UPDATE for only the required field.
Logic for handling "out of stock"
Do not automatically hide a product when stock reaches zero — the supplier may restock the next day. Correct logic:
- Quantity = 0 → the product stays active, but an "on order" flag is added
- Quantity = 0 for more than N days → notify the manager, manual decision required
- Product not found on the supplier's site 3+ times in a row → set
SUPPLIER_DISCONTINUEDflag
Flags are implemented via infoblock properties or Highload block fields.
Work timeline
| Phase | Duration |
|---|---|
| Analyzing the supplier's site, choosing the parsing method | 2–4 hours |
| Developing the stock level parser | 1–2 days |
| Configuring SKU mapping | 4–8 hours |
| Update logic in 1C-Bitrix + handling zero stock | 4–8 hours |
| Setting up schedule and monitoring | 2–4 hours |
Total: 3–5 working days per supplier. Each additional supplier adds 1–2 days (different site structures).







