function getAdditionalColumns static arIblockIDs false static arProps

 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
function getAdditionalColumns()
{
static $arIblockIDs = false;
static $arProps = false;
$res = array();
if (CModule::IncludeModule("catalog"))
{
// get iblock props from all catalog iblocks including sku iblocks
if (false === $arIblockIDs)
{
$arIblockNames = array();
$dbCatalog = CCatalog::GetList(
array(),
array(),
false,
false,
array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID', 'SKU_PROPERTY_ID', 'NAME')
);
while ($arCatalog = $dbCatalog->Fetch())
{
$arIblockIDs[] = $arCatalog["IBLOCK_ID"];
$arIblockNames[$arCatalog["IBLOCK_ID"]] = $arCatalog["NAME"];
}
}
// iblock props
if (false === $arProps)
{
$arProps = array();
foreach ($arIblockIDs as $iblockID)
{
$dbProps = CIBlockProperty::GetList(
array("SORT"=>"ASC", "NAME"=>"ASC"),
array(
"IBLOCK_ID" => $iblockID,
"ACTIVE" => "Y",
"CHECK_PERMISSIONS" => "N",
)
);
while ($arProp = $dbProps->GetNext())
$arProps[] = $arProp;
}
}
// create properties array where properties with the same codes are considered the same
$arProp2Iblock = array();
if (!empty($arProps))
{
foreach ($arProps as $id => $arProperty)
{
$arProp2Iblock["PROPERTY_".$arProperty["CODE"]][] = $arProperty["IBLOCK_ID"];
if (getNameCount($arProperty["NAME"], $arProperty["CODE"], $arProps) > 1)
$name = $arProperty["NAME"]." [".$arProperty["CODE"]."] ";
else
$name = $arProperty["NAME"];
if (array_key_exists("PROPERTY_".$arProperty["CODE"], $res))
$res["PROPERTY_".$arProperty["CODE"]] = $name." (".getIblockNames($arProp2Iblock["PROPERTY_".$arProperty["CODE"]], $arIblockNames).")";
else
$res["PROPERTY_".$arProperty["CODE"]] = $name;
}
}
}
return $res;
}