/?set_filter=y&arrFilter_5_1710230719=Y
а не /filter/brand_ref-is-company1/apply/
- это один и тот же результат фильтрации и зависит от параметров вызова компонента фильтра.<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
//define("BREND_PROPERTY_CODE", "BREND");
define("BREND_PROPERTY_CODE", "BREND");
if (empty($arResult))
return;
foreach($arResult as $arItem)
{
$SECTION_ID = array_pop(array_filter(explode('/', $arItem["LINK"])));
//Достаем количество товаров в категории
$arFilter = Array(
"IBLOCK_ID"=>$arParams["IBLOCK_ID"],
"SECTION_ID"=>$SECTION_ID ,
"INCLUDE_SUBSECTIONS"=>"Y",
"SECTION_GLOBAL_ACTIVE"=>"Y",
"SECTION_ACTIVE"=>"Y",
"ACTIVE"=>"Y",
"!DETAIL_PICTURE"=>false
);
// $arSection = CIBlockSection::GetList(Array(), $arFilter, Array("ELEMENT_SUBSECTIONS"=> true, "CNT_ACTIVE"=> true))->Fetch();
//$rsElements = CIBlockSection::GetSectionElementsCount($SECTION_ID, array("CNT_ACTIVE"=>"Y"));
$resElements = CIBlockElement::GetList(Array(), $arFilter);
$activeElements = CIBlockSection::GetSectionElementsCount($SECTION_ID, Array("CNT_ACTIVE"=>"Y"));
//$arItem["TEXT"] = $arItem["TEXT"]." (".$arSection['ELEMENT_CNT'].")";
$arItem["TEXT"] = $arItem["TEXT"]." (".$activeElements.")";
//$arItem["TEXT"] = $arItem["TEXT"];
if ($arItem["DEPTH_LEVEL"]==1)
{
$arItem["IS_PARENT"] = 1;
$arItem["PARAMS"]["IS_PARENT"] = 1;
$arResultTemp[] = $arItem;
}
if ($arItem["DEPTH_LEVEL"]==2)
{
//$arSection = CIBlockSection::GetList(Array(), $arFilter,false, array("nTopCount"=>1),array("ID","IBLOCK_ID","SECTION_PAGE_URL"))->GetNext();
//Вставляем на третий уровень список брендов
$arOrder = Array("SORT"=>"ASC", "IBLOCK_SECTION_ID" => $SECTION_ID);
$arFilter = Array("SECTION_ID"=>$SECTION_ID,"IBLOCK_ID"=>$arParams["IBLOCK_ID"],"ACTIVE_DATE"=>"Y","ACTIVE"=>"Y","INCLUDE_SUBSECTIONS"=>"Y","PROPERTY_".BREND_PROPERTY_CODE=>false);
$arGroupBy = array("PROPERTY_".BREND_PROPERTY_CODE);
$arNavStartParams = false;
$arSelectFields = Array("ID","IBLOCK_ID","PROPERTY_".BREND_PROPERTY_CODE."_ENUM_ID");
$rsBrendList = CIBlockElement::GetList(
$arOrder,
$arFilter,
$arGroupBy,
$arNavStartParams,
$arSelectFields
);
$arSortedBrands = array();
while ($arBrend = $rsBrendList->GetNext()) {
$arSortedBrands[]=$arBrend["PROPERTY_".BREND_PROPERTY_CODE."_ID"];
echo $arBrend["PROPERTY_".BREND_PROPERTY_CODE."_ID"];
}
echo $arBrend;
$arOrder = Array("SORT"=>"ASC");
/*global $USER;
if($USER->IsAdmin()) {
print_r($arSortedBrands);
echo "<br>";
}*/
//echo "<pre>";
//print_r($arSortedBrands[;
// echo "</pre>";
$arFilter = Array("IBLOCK_ID"=>23,"PROPERTY_XML_CODE"=>$arSortedBrands);
$arSelectFields = Array("ID","IBLOCK_ID","NAME","PROPERTY_XML_CODE");
$rsBrendIblockList = CIBlockElement::GetList(
$arOrder,
$arFilter,
false,
false,
$arSelectFields
);
//echo "<pre>";
//print_r($rsBrendIblockList);
//echo "</pre>";
if($rsBrendIblockList->SelectedRowsCount() > 0)
{
$arItem["IS_PARENT"] = 1;
$arItem["PARAMS"]["IS_PARENT"] = 1;
}else{
$arItem["IS_PARENT"] = '';
$arItem["PARAMS"]["IS_PARENT"] = '';
}
$arResultTemp[] = $arItem;
while ($arBrendIblock = $rsBrendIblockList->GetNextElement()) {
//echo $SECTION_ID;
//echo "<br>";
$arFields = $arBrendIblock->GetFields();
$brendPageUrl = '/catalog/'.$SECTION_ID.'/'.ToLower(BREND_PROPERTY_CODE)."/-".$arFields["PROPERTY_XML_CODE_VALUE"]."-/";
$arBrendTemp = array(
"TEXT" => $arFields['NAME'],
"LINK" => $brendPageUrl,
"SELECTED" => "",
"PERMISSION" => "X",
"ADDITIONAL_LINKS" => Array(
$brendPageUrl
),
"ITEM_TYPE" => "D",
"ITEM_INDEX" => "2",
"PARAMS" => Array(
"FROM_IBLOCK" => "",
"IS_PARENT" => "",
"DEPTH_LEVEL" => 3
),
"DEPTH_LEVEL" => 3,
"IS_PARENT" => ""
);
$arResultTemp[] = $arBrendTemp;
}
//echo "<pre>";
//print_r($arResultTemp);
//echo "</pre>";
}
// $arResult[$k]["TEXT"] = $arResult[$k]["TEXT"]." (".$arSection['ELEMENT_CNT'].")";
}
$arResult = $arResultTemp;
?>