Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementskuproperty.php
1<?php
8
10{
11 protected $ids = null;
12 protected $iblockId = 0;
13 protected $properties = array();
14
18 public function __construct($ids)
19 {
20 parent::__construct(0);
21 $this->ids = $ids;
22 }
23
31 public function setIblockId($iblockId)
32 {
33 $this->iblockId = intval($iblockId);
34 }
35
42 protected function loadFromDatabase()
43 {
44 if (!isset($this->fields) && $this->iblockId > 0 && is_array($this->ids))
45 {
46 $this->fields = array();
47 foreach($this->ids as $id)
48 {
49 if ($id > 0)
50 {
51 $propertyList = \CIBlockElement::getProperty(
52 $this->iblockId,
53 $id,
54 array("sort" => "asc"),
55 array("EMPTY" => "N")
56 );
57 while ($property = $propertyList->fetch())
58 {
59 if ($property["VALUE_ENUM"] != "")
60 {
61 $value = $property["VALUE_ENUM"];
62 }
63 elseif ($property["PROPERTY_TYPE"] === "E")
64 {
65 $value = new ElementPropertyElement($property["VALUE"]);
66 }
67 elseif ($property["PROPERTY_TYPE"] === "G")
68 {
69 $value = new ElementPropertySection($property["VALUE"]);
70 }
71 else
72 {
73 if($property["USER_TYPE"] <> '')
74 {
75 $value = new ElementPropertyUserField($property["VALUE"], $property);
76 }
77 else
78 {
79 $value = $property["VALUE"];
80 }
81 }
82
83 $this->fields[$property["ID"]][] = $value;
84 $this->fieldMap[$property["ID"]] = $property["ID"];
85 if ($property["CODE"] != "")
86 $this->fieldMap[mb_strtolower($property["CODE"])] = $property["ID"];
87 }
88 }
89 }
90 }
91 return is_array($this->fields);
92 }
93}