Development of a mega menu with banners and promotions for 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

Developing a Mega Menu with Banners and Promotions in 1C-Bitrix

A mega menu is not just navigation. In large stores, the right column of a dropdown is given over to marketing: a banner for the current promotion in a category, a list of discounted products, "new arrivals in this section". This increases promotional visibility without requiring a separate advertising slot on the page.

Managing Mega Menu Banners

Banners are associated with catalogue sections via the MegaMenuBanner HL-block:

b_uts_megamenu_banner
├── UF_SECTION_ID      — catalogue section (b_iblock_section.ID)
├── UF_IMAGE           — banner image (b_file.ID)
├── UF_TITLE           — heading (optional)
├── UF_SUBTITLE        — subheading
├── UF_LINK            — click-through URL
├── UF_ACTIVE_FROM     — display start date
├── UF_ACTIVE_TO       — display end date
├── UF_SORT            — sort order
└── UF_ACTIVE          — active flag

Managers can update banners directly from the HL-block admin interface without developer involvement.

Loading Banners When Building the Menu

namespace Local\Menu;

use Bitrix\Highloadblock\HighloadBlockTable;
use Bitrix\Main\Type\DateTime;

class MegaMenuBannerRepository
{
    public static function getForSections(array $sectionIds): array
    {
        if (empty($sectionIds)) return [];

        $hlBlock = HighloadBlockTable::getById(MEGAMENU_BANNER_HLBLOCK_ID)->fetch();
        $entity  = HighloadBlockTable::compileEntity($hlBlock);
        $dataClass = $entity->getDataClass();

        $now = new DateTime();

        $res = $dataClass::getList([
            'filter' => [
                'UF_SECTION_ID' => $sectionIds,
                'UF_ACTIVE'     => true,
                [
                    'LOGIC' => 'OR',
                    ['<=UF_ACTIVE_FROM' => $now, '>=UF_ACTIVE_TO' => $now],
                    ['UF_ACTIVE_FROM'   => false],
                ],
            ],
            'order'  => ['UF_SECTION_ID' => 'ASC', 'UF_SORT' => 'ASC'],
            'select' => ['UF_SECTION_ID', 'UF_IMAGE', 'UF_TITLE', 'UF_SUBTITLE', 'UF_LINK'],
        ]);

        $result = [];
        while ($row = $res->fetch()) {
            $sectionId = $row['UF_SECTION_ID'];
            if (!isset($result[$sectionId])) {
                $result[$sectionId] = [];
            }
            $row['UF_IMAGE_SRC'] = \CFile::ResizeImageGet(
                $row['UF_IMAGE'],
                ['width' => 280, 'height' => 180],
                BX_RESIZE_IMAGE_EXACT
            )['src'] ?? null;
            $result[$sectionId][] = $row;
        }

        return $result;
    }
}

Current Promotions in the Mega Menu

Alongside banners — a list of discounted products in the section. Discounted products are identified via b_catalog_price:

public static function getDiscountedProducts(int $sectionId, int $limit = 4): array
{
    $conn = \Bitrix\Main\Application::getConnection();

    $result = $conn->query("
        SELECT
            be.ID,
            be.NAME,
            be.DETAIL_PAGE_URL,
            be.PREVIEW_PICTURE,
            base_p.PRICE   AS price,
            sale_p.PRICE   AS sale_price
        FROM b_iblock_element be
        JOIN b_iblock_section_element bse ON bse.IBLOCK_ELEMENT_ID = be.ID
        JOIN b_catalog_price base_p
            ON base_p.PRODUCT_ID       = be.ID
            AND base_p.CATALOG_GROUP_ID = 1
        JOIN b_catalog_price sale_p
            ON sale_p.PRODUCT_ID       = be.ID
            AND sale_p.CATALOG_GROUP_ID = 2  -- 'Sale price' group
        WHERE bse.IBLOCK_SECTION_ID = {$sectionId}
          AND be.IBLOCK_ID           = " . CATALOG_IBLOCK_ID . "
          AND be.ACTIVE              = 'Y'
          AND sale_p.PRICE           < base_p.PRICE
        ORDER BY (base_p.PRICE - sale_p.PRICE) / base_p.PRICE DESC
        LIMIT {$limit}
    ");

    $products = [];
    while ($row = $result->fetch()) {
        $row['DISCOUNT_PCT'] = round(
            ($row['price'] - $row['sale_price']) / $row['price'] * 100
        );
        $row['IMAGE_SRC'] = $row['PREVIEW_PICTURE']
            ? \CFile::ResizeImageGet($row['PREVIEW_PICTURE'], ['width' => 100, 'height' => 100], BX_RESIZE_IMAGE_PROPORTIONAL)['src']
            : null;
        $products[] = $row;
    }

    return $products;
}

Mega Menu Template with Banner and Promotions

<div class="megamenu__dropdown">
    <div class="megamenu__inner megamenu__inner--with-promo">

        <!-- Subcategory navigation -->
        <div class="megamenu__nav">
            <?php foreach ($category['children'] as $sub): ?>
            <a href="<?= htmlspecialchars($sub['SECTION_PAGE_URL']) ?>"
               class="megamenu__subcat">
                <?= htmlspecialchars($sub['NAME']) ?>
            </a>
            <?php endforeach ?>
        </div>

        <!-- Discounted products -->
        <?php if (!empty($discounted[$category['ID']])): ?>
        <div class="megamenu__sales">
            <div class="megamenu__section-title">Deals in this section</div>
            <?php foreach ($discounted[$category['ID']] as $product): ?>
            <a href="<?= htmlspecialchars($product['DETAIL_PAGE_URL']) ?>"
               class="megamenu__sale-item">
                <?php if ($product['IMAGE_SRC']): ?>
                <img src="<?= $product['IMAGE_SRC'] ?>" alt="" width="56" height="56">
                <?php endif ?>
                <div>
                    <div class="megamenu__sale-name"><?= htmlspecialchars($product['NAME']) ?></div>
                    <div class="megamenu__sale-prices">
                        <span class="old"><?= number_format($product['price'], 0, '', ' ') ?> ₽</span>
                        <span class="new"><?= number_format($product['sale_price'], 0, '', ' ') ?> ₽</span>
                        <span class="badge">-<?= $product['DISCOUNT_PCT'] ?>%</span>
                    </div>
                </div>
            </a>
            <?php endforeach ?>
        </div>
        <?php endif ?>

        <!-- Banner -->
        <?php $banners = $menuBanners[$category['ID']] ?? [] ?>
        <?php if (!empty($banners[0]) && $banners[0]['UF_IMAGE_SRC']): ?>
        <div class="megamenu__banner">
            <a href="<?= htmlspecialchars($banners[0]['UF_LINK']) ?>">
                <img src="<?= $banners[0]['UF_IMAGE_SRC'] ?>"
                     alt="<?= htmlspecialchars($banners[0]['UF_TITLE'] ?? '') ?>"
                     width="280" height="180" loading="lazy">
                <?php if ($banners[0]['UF_TITLE']): ?>
                <div class="megamenu__banner-title">
                    <?= htmlspecialchars($banners[0]['UF_TITLE']) ?>
                </div>
                <?php endif ?>
            </a>
        </div>
        <?php endif ?>

    </div>
</div>

CSS Grid for Three-Column Layout

.megamenu__inner--with-promo {
    display: grid;
    grid-template-columns: 220px 1fr 300px;
    min-height: 320px;
}

.megamenu__sales {
    padding: 1rem 1.5rem;
    border-right: 1px solid #eee;
}

.megamenu__sale-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.megamenu__sale-prices .old {
    text-decoration: line-through;
    color: #999;
    font-size: 0.75rem;
}

.megamenu__sale-prices .new {
    font-weight: 600;
    color: var(--color-sale);
}

.megamenu__banner {
    position: relative;
    overflow: hidden;
}

.megamenu__banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.megamenu__banner-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,.6));
    color: #fff;
    font-weight: 600;
}

Caching and Invalidation on Promotion Changes

Banners and promotions are cached for 30 minutes (promotions change more frequently than the section structure). Invalidation fires when the banner HL-block is saved:

AddEventHandler('main', 'OnAfterHLBlockElementAdd', '\Local\Menu\MegaMenuCache::clear');
AddEventHandler('main', 'OnAfterHLBlockElementUpdate', '\Local\Menu\MegaMenuCache::clear');

Implementation Timeline

Configuration Timeline
Banners via HL-block + display in mega menu 3–4 days
+ discounted products from b_catalog_price +2 days
+ banner rotation, date-based scheduling +1–2 days