Parsing YML Feeds for Import into 1C-Bitrix
The supplier sent a YML file with 50,000 products — and you need to load them into Bitrix over the weekend. Standard tools fail: encoding issues, missing categories, offer duplicates, and image timeouts. We automate this process so you can forget about manual import. With 10+ years of Bitrix experience, we've processed over 500,000 products via YML feeds and have proven solutions that save up to 70% time on each import. Our company has been on the market for over 10 years, completed 50+ integrations, and helped clients save an average of $2,000 per month on manual labor.
Why YML is Better Than Excel for Import
Excel files from suppliers often contain merged cells, macros, non-standard date and currency formats. YML (Yandex Market Language specification) is a strict XML format, documented and easily parsed. It supports category hierarchy, multiple images, characteristics, and availability flags. Unlike Excel, YML requires no manual transformations and allows full automation of import.
Structure of a YML Feed
YML is an XML format for product feeds from Yandex. Suppliers often provide YML: the structure is documented, and the data is sufficient for a full import. It's simpler than parsing arbitrary Excel, but has its own nuances.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE yml_catalog SYSTEM "shops.dtd"> <yml_catalog date="2025-03-15 10:30"> <shop> <name>Shop Name</name> <currencies> <currency id="RUR" rate="1"/> </currencies> <categories> <category id="1">Electronics</category> <category id="2" parentId="1">Smartphones</category> </categories> <offers> <offer id="12345" available="true"> <price>29990</price> <currencyId>RUR</currencyId> <categoryId>2</categoryId> <picture>https://example.com/img/12345.jpg</picture> <name>Samsung Galaxy A54 Smartphone</name> <vendor>Samsung</vendor> <vendorCode>SM-A546</vendorCode> <description>Product description</description> <param name="Color">Black</param> <param name="Storage">128 GB</param> </offer> </offers> </shop> </yml_catalog> Key elements: offer id — unique identifier (analogous to XML_ID in Bitrix), available — availability flag, categoryId — reference to category, param — arbitrary characteristics.
Parsing Categories and Building the Tree
Categories in YML form a hierarchy via the parentId attribute. During import, you need to create the corresponding section structure in the infoblock. Algorithm:
- Load all categories into an associative array
[id => ['name' => ..., 'parentId' => ...]]. - Recursively build the tree.
- For each category: find the section by
XML_ID = 'yml_cat_{id}'or create a new one. - Save the mapping
[yml_id => bitrix_section_id].
$sectionId = CIBlockSection::GetList( [], ['IBLOCK_ID' => $iblockId, 'XML_ID' => 'yml_cat_' . $cat['id']], false, ['ID'] )->Fetch()['ID']; if (!$sectionId) { $bs = new CIBlockSection(); $sectionId = $bs->Add([ 'IBLOCK_ID' => $iblockId, 'XML_ID' => 'yml_cat_' . $cat['id'], 'NAME' => $cat['name'], 'IBLOCK_SECTION_ID' => $parentBitrixId, 'ACTIVE' => 'Y', ]); } Importing Products (Offers) and Working with Images
The main processing loop — iterating over all offers in the XML. For each, an infoblock element is created or updated. Special attention goes to image loading: with a feed of 10,000 products, that's 10,000 HTTP requests. We use URL hash checking and parallel loading via agents to reduce time by 3–5 times.
foreach ($xml->shop->offers->offer as $offer) { $xmlId = (string)$offer['id']; $available = (string)$offer['available'] === 'true'; $params = []; foreach ($offer->param as $param) { $params[(string)$param['name']] = (string)$param; } $fields = [ 'IBLOCK_ID' => $iblockId, 'NAME' => (string)$offer->name, 'XML_ID' => $xmlId, 'ACTIVE' => $available ? 'Y' : 'N', 'IBLOCK_SECTION_ID' => $sectionMap[(string)$offer->categoryId] ?? null, 'PROPERTY_VALUES' => [ 'VENDOR' => (string)$offer->vendor, 'ARTICLE' => (string)$offer->vendorCode, ], ]; $existId = getElementByXmlId($xmlId, $iblockId); $el = new CIBlockElement(); if ($existId) { $el->Update($existId, $fields); } else { $el->Add($fields); } updatePrice($existId ?: $el->LAST_ID, (float)$offer->price); } What Offer Types Does YML Support?
YML distinguishes several types, each with its own mandatory fields:
| Type | Attribute | Feature |
|---|---|---|
| Simple | type="simple" or none |
All categories, basic fields |
| Clothing | type="vendor.model" |
Fields vendor, model, size grid |
| Books | type="book" |
Fields author, publisher, ISBN |
| Audiobooks | type="audiobook" |
Specific media fields |
In practice, 80% of suppliers use the simple type. Specific types require additional property mapping.
How to Speed Up Import of Products with Images?
Images are the biggest bottleneck. Our approach: before downloading, compare the URL hash with the previous import (stored in a property). If the URL hasn't changed, skip download. For new products — background agents with a limit of 5 concurrent threads. This saves up to 70% time on a batch of 50,000 products.
Typical Errors in Parsing and How to Avoid Them
-
Encoding problems — YML comes in UTF-8, but Bitrix may expect windows-1251. Solution: convert using
iconv()before parsing. -
Missing categories — when YML specifies a
categoryIdthat doesn't exist in the category block. Solution: create missing categories with a note "Temporary". -
Offer duplicates — multiple records with the same
id. Solution: use XML_ID and check existence before adding.
Case Study
One of our clients, an electronics online store with 30,000 products from 5 suppliers, faced the main problem: different category schemas (one had 2-level nesting, another 4-level). We solved it with an intermediate mapping: a dictionary table in an HL-block. In 4 days, we developed a universal wrapper that now updates the catalog daily via Cron. The client saved $2,500 monthly on manual data entry.
What's Included
| Stage | Composition |
|---|---|
| YML feed analysis | Check structure, all offer types, encoding |
| Design | Category and property mapping scheme |
| Development | Import script with duplicate handling, logging |
| Testing | Trial import on a copy, error checking |
| Deployment and support | Agent setup, documentation, 1 month support |
Development Timelines
| Option | Time |
|---|---|
| Basic import (products, prices, categories) | 2–3 days |
| Full with characteristics and images | 4–5 days |
| Multi-supplier system with UI and deduplication | 7–10 days |
We develop both simple integrations and complex multi-feeds. Want to set up YML parsing for your store? Contact us — we'll evaluate your project in 1 day. We guarantee quality and deadlines. Order YML parsing — and forget about manual import forever.







