if defined B_PROLOG_INCLUDED B_PROLOG_INCLUDED true die CModule Includ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
CModule::IncludeModule('highloadblock');
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
$hlblockId = COLOR_HL_IBLOCK_ID;
$sortId = 'ID';
$sortType = 'DESC';
$hlblock = HL\HighloadBlockTable::getById($hlblockId)->fetch();
$entity = HL\HighloadBlockTable::compileEntity($hlblock);
$mainQuery = new Entity\Query($entity);
$mainQuery->setSelect(array('*'));
$mainQuery->setOrder(array($sortId => $sortType));
$mainQuery->setFilter(array(''));
$result = $mainQuery->exec();
$result = new CDBResult($result);
$arRows = array();
while ($arItem = $result->Fetch())
{
$arRows[] = $arItem;
}
unset($arItem);
$arFileColorIds = array();
foreach($arRows as &$arItem)
{
$arFileColorIds[] = $arItem["UF_FILE"];
}
unset($arItem);
$arFilesColor = array();
$arSort = array("id"=>"desc");
$arFilter = array(
"ID" => $arFileColorIds,
"MODULE_ID" => "main"
);
$rsFileColor = CFile::GetList(
$arSort,
$arFilter
);
while($arItem = $rsFileColor->GetNext())
{
if (!is_array($arItem["ID"]))
{
$photo = itc\Resizer::get(NO_PHOTO_ID, 'crop', 23, 23, NO_PHOTO_EXTENSION);
}
else
{
$extension = end(explode('.', '/upload/'.$arItem["SUBDIR"].'/'.$arItem["FILE_NAME"]));
$photo = itc\Resizer::get($arItem["ID"], 'crop', 23, 23, $extension);
}
$arItem["SRC_RESIZE"] = $photo;
$arFilesColor[$arItem["ID"]] = $arItem;
}
unset($arItem);
$arFilesColorReplac = array();
foreach($arRows as &$arItem)
{
$arFilesColorReplac[$arItem["UF_XML_ID"]]["UF_FILE"] = $arFilesColor[$arItem["UF_FILE"]];
}
unset($arItem);
$arColorCodes = array();
foreach($arResult["ITEMS"] as &$arItem)
{
if($arItem["CODE"] === "COLOR")
{
foreach($arItem["VALUES"] as $keyColor => &$arColor)
{
$arColor["UF_FILE"] = $arFilesColorReplac[$keyColor];
$arItem["VALUES"][$keyColor] = $arColor;
}
unset($arColor, $keyColor);
break;
}
}
unset($arItem);
?>