Parsing Supplier Price Lists for 1C-Bitrix
A supplier's price list is an Excel file, CSV table, or PDF that arrives daily, weekly, or sometimes multiple times a day. It can contain thousands of items with prices, stock levels, and characteristics. Moving this manually into a 1C-Bitrix catalog is impossible — too slow and too many errors. The parsing task is to read the supplier's price list and update catalog data automatically.
Price List Formats and Parsing Strategies
Supplier price lists are rarely standard. Each has its own structure, columns, and encoding.
| Format | Parsing Notes |
|---|---|
| Excel (.xlsx, .xls) | PhpSpreadsheet for reading; find header row, skip ads and decorative blocks |
| CSV | fgetcsv(), account for delimiter (; or ,) and encoding (Windows-1251 for Russian suppliers) |
| ODS (OpenDocument) | PhpSpreadsheet supports it |
| Most difficult: pdftotext or OCR service API; structure is lost |
Main Excel problem: each supplier makes their own format. One has article in column A, another in E. One has three header rows, another has one. The parser must be configurable: column mapping is set for each supplier.
Import System Architecture
Store supplier settings in a separate structure (infoblock or custom table):
Supplier:
- Name
- Price retrieval method (FTP / email / HTTP / Telegram)
- File format
- Column mapping: {article: A, name: B, price: C, stock: D}
- Transformation rules: {price: multiply by 1.3, name: prefix "Brand X"}
- Update schedule
- Price type in Bitrix (price list ID)
Column mapping is represented as an array passed to a universal parser class. This lets you add new suppliers without code changes.
Getting the Price List
File retrieval methods:
-
FTP/SFTP — supplier uploads file to server, script downloads on schedule. Use
ftp_connect()orphpsecliblibrary. -
HTTP link —
file_get_contents()orcurl. Some suppliers require auth — HTTP Basic or cookie session. -
Email — email with attachment. Parser connects to IMAP mailbox (
imap_open()), searches for supplier emails, downloads attachment. - Telegram bot — rare but happens: get file via Telegram Bot API.
Updating Prices and Stock in 1C-Bitrix
After parsing the file, data must be entered into the catalog. Key identifier is article (ARTICLE or XML_ID in infoblock).
Update price:
\Bitrix\Catalog\PriceTable::update($priceId, [
'PRICE' => $newPrice,
'CURRENCY' => 'RUB',
]);
// or bulk via CCatalogProduct::SetOptimalPrice()
Update stock:
\Bitrix\Catalog\StoreProductTable::update($storeProductId, [
'AMOUNT' => $newAmount,
]);
// or if not using warehouses:
CCatalogProduct::Update($productId, ['QUANTITY' => $newQty]);
Find product by article:
$result = \Bitrix\Iblock\ElementTable::getList([
'filter' => ['IBLOCK_ID' => $catalogIblockId, 'CODE' => $article],
'select' => ['ID', 'NAME'],
]);
If article not found — log as "unrecognized item" (don't create automatically, catalog clutter risk).
Logging and Quality Control
A critical part often ignored. Each import run must log:
- Number of rows in file.
- Number of updated items.
- Number of unrecognized articles (with list).
- File read errors.
- Execution time.
Log stored in "Import Log" infoblock or separate table. Email notification to admin on non-zero error count.
Performance with Large Price Lists
A 50,000-item price list with naive approach (DB query per row) will process for hours. Right strategy:
- Batch reading: read Excel in 1000-row blocks, don't load entire file in memory.
-
Article cache: before import load all existing articles into array
['ARTICLE' => 'BITRIX_ID']. Search in-memory array instead of DB query per item. - Bulk updates: instead of UPDATE per row — use transaction or batch API.
Development Timeline
| Scale | Scope | Timeline |
|---|---|---|
| Single supplier, Excel/CSV | Parser + price and stock import | 2–3 days |
| Multiple suppliers | Configurable mapping system | 4–6 days |
| Complete system | All formats, supplier management UI, logs | 7–10 days |







