Skip to content

Instantly share code, notes, and snippets.

@vladsold
Last active January 29, 2020 22:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladsold/62ec66fc28c2ec1f1be9aa607ba8b4dd to your computer and use it in GitHub Desktop.
Save vladsold/62ec66fc28c2ec1f1be9aa607ba8b4dd to your computer and use it in GitHub Desktop.
Hide empty categories in 1c-bitrix
<?
//result_modifier.php
foreach ($arResult['SECTIONS'] as $key => $value) {
$arSelect = Array("ID");
$sect = CIBlockElement::GetList(
Array("ID" => "DESC"),
Array("IBLOCK_ID" => #NUMBER_INFOBLOK#,
"ACTIVE" => "Y",
"SECTION_ID" => Array($arResult['SECTIONS'][$key]['ID']),
"INCLUDE_SUBSECTIONS" => 'Y',
"CATALOG_AVAILABLE" => "Y"
),
false,
Array("nTopCount" => 3),
$arSelect);
$count = 0;
while ($el = $sect->GetNextElement()) {
$count++;
if ($count > 1) break;
};
if ($count < 1) unset($arResult['SECTIONS'][$key]);
}
?>
@vladsold
Copy link
Author

Modify component catalog.section.list (move to local->components->bitrix) and modify result_modifier.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment