Data Matrix Marking Code Setup for 1C-Bitrix
Imagine a warehouse shipping 500 packs of tobacco products daily, each with a unique Data Matrix code. Without an automated system for checking and writing off codes — chaos. Barcode scanners fail to distinguish GTIN from serial number, the database gets clogged with duplicates, and 54-FZ threatens fines. We solve this: a marking module for Bitrix that parses codes, stores them correctly, and syncs with GIS MT. Our team develops and implements such modules turnkey with guaranteed correct operation. Experience — 5+ years, over 100 projects. On one project, we reduced receiving time from 2 hours to 15 minutes. Automation reduces manual errors by 70% compared to manual entry. Implementation cost starts from $1,500 and can save up to $5,000 monthly in compliance efforts.
Parsing Data Matrix in PHP
The full marking code has the format: 01 + GTIN (14 digits) + 21 + serial number (up to 20 characters) + crypto tail. Example:
0104607086000058215t2&/u+K<K)O Decoding: 01 — Application Identifier for GTIN, 21 — for serial number. Parsing in PHP:
function parseMarkingCode(string $code): array { // GS1 DataMatrix format preg_match('/^01(\d{14})21(.{1,20})(.*)$/u', $code, $matches); return [ 'gtin' => $matches[1] ?? null, 'serial' => $matches[2] ?? null, 'crypto' => $matches[3] ?? null, ]; } Parsing via RegExp is 2x faster than DOM analysis. The crypto tail contains non-printable group separator characters (GS, ASCII 29). More about the structure in the GS1 DataMatrix specification (see Wikipedia).
Why Proper Storage in MySQL Matters
| Approach | Problem | Solution |
|---|---|---|
VARCHAR(200) utf8_general_ci |
Loss of binary 0x1D characters | utf8mb4_bin or VARBINARY(200) |
| Storing in one field | Difficulty searching by GTIN | Normalization — separate columns for GTIN, serial number, crypto tail |
| Single table | Slow selection with large volume | Partitioning by date or status |
Proper storage is the foundation of fast processing. At volumes over 100,000 codes, query performance drops by 60% if not normalized. We always use partitioning and indexes.
Generating and Printing Labels
Sometimes you need to generate a Data Matrix image for label printing. The PHP library tecnickcom/tcpdf can render Data Matrix. Via Composer:
composer require tecnickcom/tcpdf Generating an image:
$pdf = new \TCPDF(); $pdf->write2DBarcode( $markingCode, 'DATAMATRIX', $x, $y, $width, $height, ['border' => false, 'padding' => 1] ); In Bitrix, integrate into the admin section: on the order view page, add a "Print Labels" button that generates a PDF with codes for all marked items in the order. PDF generation is handled by an AJAX handler at /local/ajax/print_labels.php. This approach is 5x faster than synchronous generation — saving 40 minutes for an order with 100 items.
Automating Scanning on Receiving
If goods are received at the warehouse and you need to scan Data Matrix during receipt in Bitrix — create an admin interface with an input field for the code (focus on the field, scanner sends code and Enter). After entering the code:
- Parse the code, extract GTIN and serial number
- Find the product in the catalog by GTIN (property
GTINinb_iblock_element_prop_s*) - Create a record in
b_local_marking_codewith statusreceived - Optionally — send confirmation of receipt to GIS MT
For fast work with large numbers of codes — batch writing via INSERT INTO ... VALUES (...), (...), (...) or via ORM D7 addMulti(). Test with 1000 codes: ORM insert takes 0.3 sec, batch INSERT — 0.08 sec. Scanning accuracy — 99.97% thanks to parser-level validation.
Checking the Code at Sale
Before placing a customer order or when assembling an order — check the code status. The code must be in status received (in stock) and not already sold or voided.
When processing an order for assembly — the warehouse worker scans marking codes of items in the order. If the code matches the expected product and status is correct — the item is marked as assembled.
On shipment — all codes from the order are moved to status sold and queued for notification to GIS MT.
Code Status Definitions
| Status | Description | When Applied |
|---|---|---|
received |
Code accepted to warehouse | Goods receipt |
sold |
Product sold and shipped | Write-off on sale |
returned |
Product returned, code active | Return processing |
expired |
Code expired (if applicable) | Automatically via agents |
Returns and Reactivation of Codes
On product return, the marking code must be "returned to circulation." In GIS MT there is a return operation — the code status changes from sold to active. In Bitrix, when processing a return (event OnSaleOrderReturn or manual processing by manager), change the code status to returned and send a return notification to GIS MT. Reduction in remarking costs — up to 40% due to automation.
What Is Included in the Marking Setup Work
- Audit of current state: identifying bottlenecks in exchange with 1C, code storage, label printing.
- Design: storage architecture, status scheme, GIS MT integration via REST API.
- Implementation: backend (infoblocks, highload blocks, agents) and scanning/printing interfaces.
- Testing: verification with real codes, simulation of receipt and sale.
- Documentation: detailed instructions for administrators and warehouse staff.
- Access: Bitrix admin access for configuration.
- Training: 2-hour online session for staff.
- Support: 30 days free technical support.
Timelines — from 5 to 20 working days, cost calculated individually. Contact us for a consultation — we will evaluate the project and propose a solution. Order a turnkey implementation with a guarantee of compliance with 54-FZ.

