Rus
Eng
Работа с разделами Битрикс и компонентом catalog.section
Order site
By contacting me you will receive a reliable and knowledgeable contractor who will quickly and efficiently implement any task for you and your business.

All English-language materials have been translated fully automatically using the Google service

Get SECTION_PAGE_URL on d7

$parentFilter = [
	'select' => [
		'ID',
		'NAME',
		'IBLOCK_ID',
		'IBLOCK_SECTION_ID',
		'CODE',
		'SECTION_PAGE_URL_RAW' => 'IBLOCK.SECTION_PAGE_URL'
	],
	'filter' => [
		'=IBLOCK_ID' => $arParams["IBLOCK_ID"]
		'=ID' => $SECTION_ID
	],
	'cache' => array(
		'ttl' => 86400, // Время жизни кеша сутки
		//'cache_joins' => true // Кешировать ли выборки с JOIN
	)
];

$parentSection = \Bitrix\Iblock\SectionTable::getList($parentFilter)->fetch();
$parentSection['SECTION_PAGE_URL'] = \CIBlock::ReplaceDetailUrl($parentSection['SECTION_PAGE_URL_RAW'], $parentSection, true, 'S');

Getting the first level parent section

$connection = \Bitrix\Main\Application::getConnection();
$PARENT_ID = $arResult['IBLOCK_SECTION_ID'];
$FIRST_LEVEL_SECTION = $connection->query('SELECT bis.ID FROM b_iblock_section as bis LEFT JOIN b_iblock_section as bis2 ON bis2.ID = ' . $PARENT_ID . ' where bis.LEFT_MARGIN < bis2.LEFT_MARGIN AND bis.RIGHT_MARGIN > bis2.RIGHT_MARGIN AND bis.IBLOCK_ID = bis2.IBLOCK_ID  AND bis.DEPTH_LEVEL = 1')->fetch();
\Bitrix\Iblock\SectionTable::getList([
	'select' => ['ID', 'INNER_ID' => 'INNER_SECTION.ID'],
	'filter' => [
		'IBLOCK_ID' => $IBLOCK_ID,
		'ID' => [$SECTION_IDS]
	],
	'runtime' => [
		'INNER_SECTION' => [
			'data_type' => \Bitrix\Iblock\SectionTable::class,
			'reference' => [
				'<this.LEFT_MARGIN' => 'ref.LEFT_MARGIN',
				'>this.RIGHT_MARGIN' => 'ref.RIGHT_MARGIN',
				'this.IBLOCK_ID' => 'ref.IBLOCK_ID'
			],
			'join_type' => 'LEFT'
		]
	]
])->fetchAll();

Getting all subsections of a section, including nested ones

Getting section data by its code in Bitrix

$section = \Bitrix\Iblock\SectionTable::query()
	->where('IBLOCK_ID', $iblockId)
	->where('CODE', 'КОД РАЗДЕЛА')
	->where('ACTIVE', 'Y')
	->setSelect(['*'])
	->exec()
	->fetch()
;

Getting a custom section property

\Bitrix\Main\Loader::includeModule("iblock");
$entity = \Bitrix\Iblock\Model\Section::compileEntityByIblock($IBLOCK_ID);
$attendant = $entity::getList(array(
	"select" => array("UF_ATTENDANT", "ID", "NAME"),
	"filter" => array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "ID" => $intSectionID, "GLOBAL_ACTIVE" => "Y")
))->fetch();

Get all sections to which the element is attached

\Bitrix\Iblock\ElementTable::getList([
            'filter' => [
                '=ID' => $ELEMENT_ID,
            ],
            'select' => [
                'ID',
                'NAME',
                'SECTION_ELEMENT_ID' => 'SECTION_ELEMENT.IBLOCK_SECTION_ID',
            ],
            'runtime' => [
                new \Bitrix\Main\ORM\Fields\Relations\Reference(
                    'SECTION_ELEMENT',
                    \Bitrix\Iblock\SectionElementTable::class,
                    \Bitrix\Main\Entity\Query\Join::on('this.ID', 'ref.IBLOCK_ELEMENT_ID')
                )
            ],
        ])->fetchAll()

Displaying products in the catalog.section component from several sections

First of all, and reset the values of the current binding to the sections. For example like this:

$arResult["VARIABLES"]["SECTION_CODE"] = '';
$arResult["VARIABLES"]["ID"] = '';

Add the following options to the call parameters of the component:

"INCLUDE_SUBSECTIONS" => "Y",
"SHOW_ALL_WO_SECTION" => "Y",

Pass the correct values to the filter. For example like this:

global $arrFilter;

$arrFilter['SECTION_ID'] = [35, 77];

If you did everything right and there is no additional. factors (for example, filter overrides), then your component will display products from the specified sections

Bitrix. Sort products without price to the end of the list

To do this, just specify in $arParams catalog.section or catalog

$arParams["ELEMENT_SORT_ORDER"] = "asc,nulls";

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Please message me to discuss the task. I work remotely and officially (as a self-employed professional); my hourly rate is 1,800 RUB, and I can dedicate 3–4 hours a day to the project. I respond quickly, and the consultation is free.

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site