Integration of 1C-Bitrix with MoySklad
An online store on 1C-Bitrix and MoySklad (cloud commerce management system) is a common combination for small and medium businesses. However, Bitrix lacks a native integration module, and ready-made marketplace solutions cover 60-70% of scenarios. The remainder — non-standard property mapping, stock synchronization across warehouses, characteristic processing — requires custom development. Let's examine the integration architecture, MoySklad API, and typical issues.
What We Synchronize
Bitrix ↔ MoySklad integration typically includes four data streams:
| Stream | Direction | Frequency | Priority |
|---|---|---|---|
| Products and prices | MoySklad → Bitrix | Every 15-60 min | High |
| Stock by warehouses | MoySklad → Bitrix | Every 5-15 min | Critical |
| Orders | Bitrix → MoySklad | On event (at checkout) | Critical |
| Order statuses | MoySklad → Bitrix | Every 5-15 min | Medium |
"MoySklad as master" for products is typical. Content manager works in MoySklad, site receives up-to-date data. Reverse product synchronization (Bitrix → MoySklad) is rarely needed and creates conflict risks.
MoySklad API: Remap API 1.2
MoySklad provides REST API (JSON API 1.2) at https://api.moysklad.ru/api/remap/1.2/. Authentication — Basic Auth or Bearer Token.
Key endpoints:
-
GET /entity/product— product list. Supports filtering (filter=updated>2024-03-01), pagination (limit,offset), expansion of nested entities (expand=group,productFolder). -
GET /entity/assortment— unified list of products, modifications, kits, and services. More convenient thanproductwhen you need everything at once. -
GET /report/stock/all— stock for all products. Can filter by warehouse (stockstore). -
POST /entity/customerorder— creating customer order. -
GET /entity/customerorder/{id}— getting order with statuses.
API Limitations:
- Rate limit: 45 requests per 3 seconds per account. Exceeding returns HTTP 429. Parser should account for delays.
- Maximum 1000 objects per response. For full catalog export, pagination is needed.
- Webhook notifications (MoySklad → your server) — available but unreliable: no delivery guarantee, no retries. For critical data (stock), use polling.
Product Synchronization
Incremental synchronization algorithm:
- Request
GET /entity/assortment?filter=updated>${lastSyncTime}&limit=1000. - For each product, find correspondence in Bitrix iblock by external code (
XML_ID= UUID of product in MoySklad). - If found —
CIBlockElement::Update()with updated fields. - If not found —
CIBlockElement::Add(). - Save
lastSyncTime = now()inb_option.
Field Mapping — core of integration. Correspondence table:
| MoySklad | Bitrix (iblock) | Notes |
|---|---|---|
name |
NAME |
— |
description |
DETAIL_TEXT |
HTML or plain text |
article |
PROPERTY_ARTICLE |
Property code depends on iblock |
salePrices[0].value |
CATALOG_PRICE_1 |
Price in kopecks → divide by 100 |
buyPrice.value |
CATALOG_PRICE_2 (purchase price) |
If used |
images[].filename |
DETAIL_PICTURE / MORE_PHOTO |
Download via URL from miniature.href |
productFolder.name |
iblock section | Create section if doesn't exist |
Characteristics (modifications) in MoySklad are variant inside product. In Bitrix they correspond to trade offers (SKU) in a separate iblock. Each variant → SKU-iblock element with binding to parent product via CHL_LINK (property CML2_LINK).
Stock Synchronization
Stock is the most sensitive stream. Selling out-of-stock product — direct losses.
Call GET /report/stock/all with filter by warehouses participating in online sales. Result contains assortmentId and quantity. Update CATALOG_QUANTITY field in b_catalog_product or via \Bitrix\Catalog\ProductTable::update().
For displaying stock by warehouses on site (e.g., "in stock at Lenin Store"), use Bitrix warehouse accounting mechanism: module catalog, table b_catalog_store_product. Each MoySklad warehouse maps to Bitrix warehouse (b_catalog_store).
Frequency: every 5 minutes via cron script. Bitrix agents for this task are unsuitable — they're tied to hits and don't guarantee interval.
Order Transmission
When order is placed in Bitrix (event OnSaleOrderSaved or OnSaleComponentOrderComplete), create order in MoySklad via POST /entity/customerorder.
Request body structure:
{
"organization": {"meta": {"href": "...entity/organization/{id}"}},
"agent": {"meta": {"href": "...entity/counterparty/{id}"}},
"positions": [
{
"assortment": {"meta": {"href": "...entity/product/{id}"}},
"quantity": 2,
"price": 150000
}
]
}
Counterparty (agent) — buyer. On first order, create via POST /entity/counterparty, on repeat — search by email/phone. Save counterparty UUID in custom order property in Bitrix or in user UF_-field.
Error Handling and Queue
Network is unreliable, MoySklad API sometimes returns 500. For orders use queue: on send error, save order to parser_queue table (or b_sale_order with "not sent to MoySklad" flag), agent retries every 5 minutes. Max 5 attempts, then — notify manager.
For products and stock, queue isn't needed — next sync cycle will pick up changes.
Timelines
| Stage | Time |
|---|---|
| Catalog structure analysis + field mapping | 1-2 days |
| Product + category synchronization | 3-4 days |
| Stock synchronization by warehouse | 1-2 days |
| Order transmission + counterparties | 2-3 days |
| Reverse status synchronization | 1 day |
| Testing, debugging, edge cases | 2-3 days |
| Total | 1-2 weeks |







