Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
iblockvalues.php
1<?php
8
10{
14 public function __construct($iblockId)
15 {
16 parent::__construct($iblockId);
17 }
18
24 public function getValueTableName()
25 {
26 return "b_iblock_iblock_iprop";
27 }
28
34 public function getType()
35 {
36 return "B";
37 }
38
44 public function getId()
45 {
46 return $this->iblockId;
47 }
48
54 public function createTemplateEntity()
55 {
56 return new \Bitrix\Iblock\Template\Entity\Iblock($this->iblockId);
57 }
58
64 public function getParents()
65 {
66 return array();
67 }
68
75 public function queryValues()
76 {
77 $result = array();
78 if ($this->hasTemplates())
79 {
80 $connection = \Bitrix\Main\Application::getConnection();
81 $query = $connection->query("
82 SELECT
83 P.ID
84 ,P.CODE
85 ,P.TEMPLATE
86 ,P.ENTITY_TYPE
87 ,P.ENTITY_ID
88 ,IP.VALUE
89 FROM
90 b_iblock_iblock_iprop IP
91 INNER JOIN b_iblock_iproperty P ON P.ID = IP.IPROP_ID
92 WHERE
93 IP.IBLOCK_ID = ".$this->iblockId."
94 ");
95
96 while ($row = $query->fetch())
97 {
98 $result[$row["CODE"]] = $row;
99 }
100
101 if (empty($result))
102 {
103 $sqlHelper = $connection->getSqlHelper();
104 $result = parent::queryValues();
105 $fields = array(
106 "IBLOCK_ID",
107 "IPROP_ID",
108 "VALUE",
109 );
110 $rows = array();
111 foreach ($result as $row)
112 {
113 $rows[] = array(
114 $this->iblockId,
115 $row["ID"],
116 $sqlHelper->forSql($row["VALUE"]),
117 );
118 }
119 $this->insertValues("b_iblock_iblock_iprop", $fields, $rows);
120 }
121 }
122 return $result;
123 }
124
130 function clearValues()
131 {
132 $connection = \Bitrix\Main\Application::getConnection();
133 $connection->query("
134 DELETE FROM b_iblock_element_iprop
135 WHERE IBLOCK_ID = ".$this->iblockId."
136 ");
137 $connection->query("
138 DELETE FROM b_iblock_section_iprop
139 WHERE IBLOCK_ID = ".$this->iblockId."
140 ");
141 $connection->query("
142 DELETE FROM b_iblock_iblock_iprop
143 WHERE IBLOCK_ID = ".$this->iblockId."
144 ");
145 }
146}
insertValues($tableName, $fields, $rows)