Setting Up Contract Prices for Dealers in 1C-Bitrix
Contract price is a price fixed in agreement for specific SKU for specific dealer. Doesn't depend on group discounts and valid strictly during contract term. Task — implement exactly this priority: contract price overrides everything else, but only for those positions and only during contract period.
Why Standard Discounts Don't Work
The catalog module provides discounts (CCatalogDiscount) and price types (b_catalog_group). Discounts set in percentages or fixed amounts, applied to price type. For contract prices doesn't fit: contract price — absolute value, not derived from base. If base price changed, contract stays same.
Storing Contract Prices
Create Highload block dealer_contract_prices. Table generated automatically by block name. Fields:
| Field | Type | Description |
|---|---|---|
UF_DEALER_ID |
Integer | Dealer company ID |
UF_PRODUCT_ID |
Integer | Product ID in infoblock |
UF_XML_ID |
String | SKU (for 1C sync) |
UF_PRICE |
Double | Contract price |
UF_CURRENCY |
String | Currency |
UF_DATE_FROM |
DateTime | Start of validity |
UF_DATE_TO |
DateTime | End of validity |
UF_ACTIVE |
Boolean | Active status |
Index on (UF_DEALER_ID, UF_PRODUCT_ID, UF_ACTIVE) — mandatory, otherwise large dataset queries slow.
Price Application Logic
Implemented via custom price provider, hooked to OnSaleBasketBeforeSaved event or via Bitrix\Catalog\v2\Price extension. Algorithm:
- Determine current user's dealer company from session
- Search
dealer_contract_pricesfor record withUF_DEALER_ID= company,UF_PRODUCT_ID= product,UF_DATE_FROM≤ today ≤UF_DATE_TO,UF_ACTIVE= true - If found — use
UF_PRICEas final price, ignore group price type - If not found — fallback to dealer's standard price type by group in
b_catalog_price
Result cached in memcached/Redis by key contract_price_{dealerId}_{productId} for 1 hour. Invalidation — on Highload block record update via OnAfterHLBlockElementUpdate event handler.
Loading Contract Prices from 1C
Contract prices maintained in 1C. Sync via agent:
- 1C exports XML with contract positions: dealer (1C code), SKU, price, period
- Bitrix agent reads file, finds dealer by
UF_1C_IDin company Highload block - Finds product by
XML_IDinb_iblock_element - Creates/updates record in
dealer_contract_prices - Marks expired records
UF_ACTIVE= false
Sync frequency — on 1C price update (event-driven) or cron 2 times daily.
Display in Catalog
For authorized dealer, show label "Contract" or "By agreement #..." near price. Gives confidence price applied correctly. Implemented in result_modifier.php of catalog component: add IS_CONTRACT_PRICE flag and agreement number to product data.
Setup of storage and contract price application logic: 1–2 weeks. Including integration with 1C export — 2–3 weeks.







