Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
iblock.php
1<?php
8
9class Iblock extends Base
10{
11 protected $catalog = null;
12
16 public function __construct($id)
17 {
18 parent::__construct($id);
19 $this->fieldMap = array(
20 "name" => "NAME",
21 "previewtext" => "DESCRIPTION",
22 "detailtext" => "DESCRIPTION",
23 "code" => "CODE",
24 );
25 }
26
34 public function resolve($entity)
35 {
36 if ($entity === "catalog")
37 {
38 if (!$this->catalog && $this->loadFromDatabase())
39 {
40 if (\Bitrix\Main\Loader::includeModule('catalog'))
41 $this->catalog = new ElementCatalog(0);
42 }
43
44 if ($this->catalog)
45 return $this->catalog;
46 }
47 return parent::resolve($entity);
48 }
49
56 protected function loadFromDatabase()
57 {
58 if (!isset($this->fields))
59 {
60 $elementList = \Bitrix\Iblock\IblockTable::getList(array(
61 "select" => array_values($this->fieldMap),
62 "filter" => array("=ID" => $this->id),
63 ));
64 $this->fields = $elementList->fetch();
65 }
66 return is_array($this->fields);
67 }
68}