63 lines
2.0 KiB
PHP
63 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 = [
|
|
'BRAND_TITLE' => "",
|
|
'MODELS' => [],
|
|
];
|
|
|
|
$brands = [];
|
|
$brands_res = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_BRANDS, ], false, []);
|
|
while ($brands_ob_element = $brands_res->GetNextElement())
|
|
{
|
|
$brands_ar_res = $brands_ob_element->GetFields();
|
|
$brands_ar_res['PROPERTIES'] = $brands_ob_element->GetProperties();
|
|
$brands[$brands_ar_res['CODE']] = [
|
|
"NAME" => $brands_ar_res['NAME'],
|
|
"CODE" => $brands_ar_res['CODE'],
|
|
"UID" => $brands_ar_res['PROPERTIES']['UID']['VALUE'],
|
|
];
|
|
}
|
|
|
|
//print "<!-- BRANDS >>>>>";
|
|
//print_r($brands);
|
|
//print "-->";
|
|
|
|
$arResult['TITLE'] = $arParams['RECOMMENDED'] ? "Каталог автомобилей ".$brands[$arParams['BRAND']]['NAME'] : "";
|
|
|
|
$models_res = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_MODELS, "PROPERTY_BRAND_UID" => $brands[$arParams['BRAND']]['UID'] ], false, []);
|
|
while ($models_ob_element = $models_res->GetNextElement())
|
|
{
|
|
$models_ar_res = $models_ob_element->GetFields();
|
|
$models_ar_res['PROPERTIES'] = $models_ob_element->GetProperties();
|
|
|
|
if(isset($models_ar_res['PREVIEW_PICTURE']))
|
|
{
|
|
$models_ar_res['PREVIEW_PICTURE'] = CFile::GetPath($models_ar_res['PREVIEW_PICTURE']);
|
|
$models_ar_res['URL'] = "/catalog/".$brands[$arParams['BRAND']]['CODE']."/".$models_ar_res['CODE']."/";
|
|
}
|
|
|
|
$arResult['MODELS'][] = $models_ar_res;
|
|
}
|
|
|
|
$this->IncludeComponentTemplate();
|
|
}
|
|
//}
|