Development of a product recommendation system 1C-Bitrix

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
    1177
  • 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

Product Recommendation System Development for 1C-Bitrix

A recommendation system is an engine that solves the problem: which product to show a specific user at a specific moment to increase the probability of a purchase. Bitrix's built-in toolset offers only manual configuration of product relationships. A full-featured recommendation system is a separate development effort involving behavioral data analysis.

Recommendation Algorithms

The choice of algorithm depends on data volume and quality requirements:

Content-based filtering (based on product properties). Recommend products similar in characteristics: same category, similar price range, shared tags. Works without purchase history, suitable for new users.

function getContentBasedRecommendations(int $productId, int $limit = 10): array {
    $product  = \CIBlockElement::GetByID($productId)->GetNext();
    $iblockId = $product['IBLOCK_ID'];
    $price    = \CPrice::GetBasePrice($productId)['PRICE'];
    $sectionId = $product['IBLOCK_SECTION_ID'];

    // Products from the same category within ±30% price range
    $result = \CIBlockElement::GetList(
        ['RAND' => 'ASC'],
        [
            'IBLOCK_ID'          => $iblockId,
            'IBLOCK_SECTION_ID'  => $sectionId,
            '!ID'                => $productId,
            '>=CATALOG_PRICE_1'  => $price * 0.7,
            '<=CATALOG_PRICE_1'  => $price * 1.3,
            'ACTIVE'             => 'Y',
        ],
        false,
        ['nPageSize' => $limit],
        ['ID', 'NAME', 'DETAIL_PAGE_URL', 'PREVIEW_PICTURE']
    );

    $items = [];
    while ($item = $result->GetNext()) {
        $items[] = $item;
    }
    return $items;
}

Collaborative filtering. "Users who viewed this product also viewed..." Requires accumulated view and purchase history.

Data for collaborative filtering is collected from:

  • b_sale_basket and b_sale_order — actual purchases.
  • Custom table custom_product_views — product page views.
  • b_sale_fuser — guest users.

Matrix factorization (ALS/SVD). Advanced algorithm requiring libraries (Python: implicit, surprise). Move recommendation calculation to a separate Python microservice, save results to Redis/PostgreSQL, and Bitrix only reads them.

Collecting Behavioral Data

// Product view tracking
// Called in the catalog.element component template
$userId  = $USER->GetID() ?: 0;
$fuserId = (int)\Bitrix\Sale\Fuser::getId();

$db->query("
    INSERT INTO custom_product_views (product_id, user_id, fuser_id, viewed_at)
    VALUES (?, ?, ?, NOW())
    ON DUPLICATE KEY UPDATE view_count = view_count + 1, viewed_at = NOW()
", [$productId, $userId, $fuserId]);
CREATE TABLE custom_product_views (
    id         SERIAL PRIMARY KEY,
    product_id INT NOT NULL,
    user_id    INT DEFAULT 0,
    fuser_id   INT NOT NULL,
    view_count INT DEFAULT 1,
    viewed_at  DATETIME,
    UNIQUE KEY uk_product_fuser (product_id, fuser_id),
    INDEX idx_fuser (fuser_id),
    INDEX idx_product (product_id)
);

Calculating "Users Also Viewed"

-- Products most frequently viewed together with $productId
SELECT
    v2.product_id,
    COUNT(DISTINCT v2.fuser_id) AS co_views
FROM custom_product_views v1
JOIN custom_product_views v2
    ON v1.fuser_id = v2.fuser_id
    AND v2.product_id != v1.product_id
    AND v2.viewed_at BETWEEN DATE_SUB(v1.viewed_at, INTERVAL 1 HOUR)
                         AND DATE_ADD(v1.viewed_at, INTERVAL 1 HOUR)
WHERE v1.product_id = :productId
GROUP BY v2.product_id
ORDER BY co_views DESC
LIMIT 20;

Results are cached in Redis for 6–24 hours. Recalculated by a Bitrix agent overnight for all popular products.

Personalization for Logged-In Users

For authenticated users, we look at the browsing history from the last 30 days:

function getPersonalizedRecommendations(int $userId, int $limit = 12): array {
    // User's recently viewed categories
    $recentCategories = getRecentUserCategories($userId, 5);

    // Products from those categories that the user hasn't viewed yet
    return \CIBlockElement::GetList(
        ['CATALOG_PRICE_1' => 'ASC'],
        [
            'IBLOCK_ID'         => CATALOG_IBLOCK_ID,
            'IBLOCK_SECTION_ID' => $recentCategories,
            '!ID'               => getViewedProductIds($userId),
            'ACTIVE'            => 'Y',
        ],
        false,
        ['nPageSize' => $limit],
        ['ID', 'NAME', 'DETAIL_PAGE_URL', 'PREVIEW_PICTURE']
    );
}

Administrative Recommendation Management

The system allows:

  • Viewing click statistics for recommendations (CTR per algorithm).
  • Adding manual recommendations (pins) for individual products.
  • Excluding products from recommendations (sold out, seasonal).
  • A/B testing algorithms: half of users see content-based, half see collaborative.

Timeline

Component Timeline
View and purchase data collection 2–3 days
Content-based recommendations 2–3 days
Collaborative filtering (SQL approach) 3–5 days
Caching + recalculation agent 1–2 days
Personalization for logged-in users 2–3 days
Admin panel + A/B test 3–4 days
Testing 2–3 days

Total: 2.5–3.5 weeks for the full system. Content-based recommendations without personalization — 1 week.