Setting up contract prices for 1C-Bitrix dealers

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

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:

  1. Determine current user's dealer company from session
  2. Search dealer_contract_prices for record with UF_DEALER_ID = company, UF_PRODUCT_ID = product, UF_DATE_FROM ≤ today ≤ UF_DATE_TO, UF_ACTIVE = true
  3. If found — use UF_PRICE as final price, ignore group price type
  4. 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:

  1. 1C exports XML with contract positions: dealer (1C code), SKU, price, period
  2. Bitrix agent reads file, finds dealer by UF_1C_ID in company Highload block
  3. Finds product by XML_ID in b_iblock_element
  4. Creates/updates record in dealer_contract_prices
  5. 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.