Setting up a Favorites List in 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
    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

Favorites List Configuration in 1C-Bitrix

Favorites list (bookmarks, wishlist) — there's no standard built-in Bitrix component that implements full wishlist with database storage. Functionality is implemented via "Deferred Items" mechanism from sale module or via custom development using UserFieldManager or separate table.

Option 1: Deferred Items (Built-in Mechanism)

The sale module has built-in "deferred" basket items mechanism. Product is added to basket with flag DELAY = Y. Technically this is a row in b_sale_basket with deferred marker:

// Add product to deferred
$basket = \Bitrix\Sale\Basket::loadItemsForFUser(
    \Bitrix\Sale\Fuser::getId()
);
$item = $basket->createItem('catalog', $productId);
$item->setFields([
    'QUANTITY' => 1,
    'DELAY'    => 'Y',
    'NAME'     => $productName,
    'PRICE'    => $price,
    'CURRENCY' => 'RUB',
]);
$basket->save();

Component bitrix:sale.basket.basket displays deferred items with parameter SHOW_DELAY = Y.

Drawback: deferred items are part of basket, not separate list. On basket clearing, they're lost.

Option 2: Custom Favorites List

For full functionality: storage between sessions, synchronization between devices, list independent from basket — need separate table or custom fields.

Table structure user_favorite_products:

CREATE TABLE user_favorite_products (
    ID SERIAL PRIMARY KEY,
    USER_ID INT NOT NULL,
    PRODUCT_ID INT NOT NULL,
    DATE_ADD TIMESTAMP DEFAULT NOW(),
    UNIQUE(USER_ID, PRODUCT_ID)
);

ORM class via DataManager allows working with table via standard Bitrix API. AJAX endpoint for add/remove — via \Bitrix\Main\Engine\Controller.

For Guests: localStorage Storage

For unregistered users favorites list is more convenient to store in browser localStorage. On authorization — synchronize with database via AJAX. This is standard approach for modern stores.

Component and UI

"Add to Favorites" button is placed in product card and listing templates. Button state (added/not added) is managed by JavaScript class based on data passed to component or obtained via AJAX.

Timeframe

Favorites via deferred items mechanism — 2–4 hours. Full custom list with guest/authorized synchronization — 1–2 business days.