Quality Documents Attachment to Products Setup in 1C-Bitrix
Quality documents — broader concept than compliance certificates. Includes: TR TS declarations, quality passports, test protocols, SgR (government registration certificates), usage instructions. Each document type has different storage and display requirements.
Document Storage Structure
For flexible attachment of multiple document types, separate infoblock optimal.
"QUALITY_DOCS" Infoblock (standard content type, not catalog):
| Property | Code | Type | Description |
|---|---|---|---|
| Document Type | DOC_TYPE |
List | Declaration / Certificate / Quality Passport / SgR |
| File | FILE |
File | PDF or image |
| Document Number | DOC_NUMBER |
String | Declaration/certificate number |
| Valid Until | VALID_TO |
Date | Expiration date |
| Products | PRODUCTS |
Infoblock Link | Multiple, product IDs |
| Trademarks | BRANDS |
Infoblock Link | Optional, if covers brand entirely |
"One Document — Many Products" Attachment
TR TS declaration usually issued for product series or entire trademark. Property PRODUCTS in documents infoblock is multiple — one document references product list.
On product card output, do reverse query:
$docsRes = \CIBlockElement::GetList(
['PROPERTY_VALID_TO' => 'DESC'],
[
'IBLOCK_ID' => QUALITY_DOCS_IBLOCK_ID,
'PROPERTY_PRODUCTS' => $productId,
'ACTIVE' => 'Y',
],
false,
false,
['ID', 'NAME', 'PROPERTY_DOC_TYPE', 'PROPERTY_FILE',
'PROPERTY_DOC_NUMBER', 'PROPERTY_VALID_TO']
);
$docs = [];
while ($doc = $docsRes->GetNext()) {
$docs[] = $doc;
}
Expiration Control
Expired documents can't be shown as current. Processing variants:
Option 1 — Filter in query:
'>=PROPERTY_VALID_TO' => date('d.m.Y')
Option 2 — Auto-deactivation via agent.
Create Bitrix agent (table b_agent) that checks expired documents daily and sets ACTIVE = N. Register via \CAgent::AddAgent():
\CAgent::AddAgent(
'\Local\QualityDocs\Agent::deactivateExpired();',
'local_quality_docs',
'N', // not one-time
86400 // daily
);
Batch Document Attachment
If attaching one document to hundreds products — manual via admin inconvenient. Create import via CIBlockElement::Update() with PRODUCTS property update. Or create admin page with product search by filter (category, brand) and batch attachment.
For batch attachment of all brand products to document:
$productIds = [];
$res = \CIBlockElement::GetList(
[],
['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'PROPERTY_BRAND' => $brandId],
false, false, ['ID']
);
while ($row = $res->Fetch()) {
$productIds[] = ['VALUE' => $row['ID']];
}
\CIBlockElement::SetPropertyValueCode(
$docElementId,
'PRODUCTS',
$productIds
);
Expiring Document Notifications
Useful addition: 30 days before document expiration — notification to responsible manager. Via same agent: find documents with VALID_TO in range today+30 days, send email via \CEvent::Send() with notification template.
| Stage | Time |
|---|---|
| Create quality documents infoblock | 2–3 h |
| Product card rework | 3–4 h |
| Agent for expired document deactivation | 2–3 h |
| Batch attachment page (optional) | 4–6 h |
| Expiration notifications (optional) | 2–3 h |







