A
A
Arthur2018-08-15 15:02:15
CMS
Arthur, 2018-08-15 15:02:15

How to display the name of the collection in the product card in Bitrix?

On the main page, choosing "Collections", then select any collection, for example, "Squalo" - select any product - and there is no way to return from it back to the collection in breadcrumbs.
How to display the collection name in breadcrumbs on the product page?
Breadcrumb pages with collections:

<div class="menu">
<a href="/">Главная</a> / <a href="/collection/">Коллекции</a> / <a href="/collection/<?=$secion['CODE']?>/"><?=$secion['NAME']?></a>
</div>

Breadcrumbs product page:
<div class="menu">
<a href="/">Главная</a> / <a href="/catalog/">Каталог</a> / <a href="/catalog/cat/<?=$arResult['IBLOCK_SECTION_ID']?>/"><?=$section_name?></a>
</div>

Simply adding this code does not help:
<a href="/collection/<?=$secion['CODE']?>/"><?=$secion['NAME']?></a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-08-15
@arturweb01

1 You started to reinvent the wheel for crumbs in vain - there is a built-in component.
2 Naturally does not work - the section code is the section code, and id is id. You have code navigation, you are trying to use id on the product page. Just adding code will definitely help if you have it in $secion.
But apparently it doesn't exist. And where do you get $secion on the product page, no one except you knows.
As a last resort, since you have a section id in $arResult['IBLOCK_SECTION_ID'] you can directly get this section using CIBlockSection::GetList by id and take CODE from this data.
Something like this:

$arSelect = Array(
      'ID',
      'CODE'
    );
  $arFilter = Array(
      'IBLOCK_ID'=> $arResult['IBLOCK_ID'],
      'ID' => $arResult['IBLOCK_SECTION_ID']
    );
  $db_res = CIBlockSection::GetList(
      Array(),
      $arFilter,
      true,
      $arSelect
    );
  if ($ar_result = $db_res->GetNext()) {
    $CODE = $ar_result['CODE'];
  }

$CODE will be your section code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question