2024-05-02 15:25:32 +03:00

78 lines
2.0 KiB
PHP

<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
/** @var CBitrixComponent $this */
/** @var array $arParams */
/** @var array $arResult */
/** @var string $componentPath */
/** @var string $componentName */
/** @var string $componentTemplate */
/** @global CDatabase $DB */
/** @global CUser $USER */
/** @global CMain $APPLICATION */
use Bitrix\Main\Context,
Bitrix\Main\Type\DateTime,
Bitrix\Main\Loader,
Bitrix\Iblock;
if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
{
if(CModule::IncludeModule('iblock'))
{
$arResult = [
'SECTIONS' => [],
];
$sort = [ "SORT" => "ASC" ];
$filter = [ "ACTIVE" => "Y", "IBLOCK_ID" => $arParams['IBLOCK_ID'] ];
$options = false;
$brands_ids = [];
if(isset($arParams['TYPE']))
{
$res_filter = CIBlockElement::GetList(
[ "SORT" => "ASC" ],
[ "ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_PROGRAMS_AGGREGATION_RULES_SPECIAL, "PROPERTY_VEHICLE_TYPE" => $arParams['TYPE'], "!PROPERTY_VEHICLE_BRAND" => false, ],
false, false, ['ID', 'NAME', 'PROPERTY_VEHICLE_BRAND']
);
while ($element_filter = $res_filter->GetNextElement())
{
$ar_res_filter = $element_filter->GetFields();
array_push($brands_ids, $ar_res_filter['PROPERTY_VEHICLE_BRAND_VALUE']);
}
}
if(count($brands_ids) > 0)
{
$filter['ID'] = $brands_ids;
}
/* $sec_res = CIBlockSection::GetList($sort, $filter, false, [], false);
while ($section = $sec_res->GetNext())
{
if(!empty($section['PICTURE']))
{
}
$section['ITEMS'] = [];
$filter = array_merge($filter, [ "SECTION_ID" => $section['ID'] ]);
*/
$res = CIBlockElement::GetList($sort, $filter, false, $options);
while ($element = $res->GetNextElement())
{
$ar_res = $element->GetFields();
$ar_res['PREVIEW_PICTURE'] = CFile::GetPath($ar_res['PREVIEW_PICTURE']);
$arResult['ITEMS'][] = $ar_res;
}
//if(count($section['ITEMS']) > 0)
//{
// $arResult['SECTIONS'][] = $section;
//}
// }
$this->IncludeComponentTemplate();
}
}