1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
elementcatalog.php
См. документацию.
1
<?php
7
namespace
Bitrix\Iblock\Template\Entity;
8
9
use Bitrix\Catalog;
10
11
class
ElementCatalog
extends
Base
12
{
13
protected
$price
=
null
;
14
protected
$sku
=
null
;
15
protected
$store
=
null
;
16
20
public
function
__construct
($id)
21
{
22
parent::__construct($id);
23
$this->fieldMap =
array
(
24
"weight"
=>
"WEIGHT"
,
25
"measure"
=>
"MEASURE"
,
26
"store"
=>
"STORE"
,
27
);
28
}
29
37
public
function
resolve
(
$entity
)
38
{
39
if
(
$entity
===
"price"
)
40
{
41
if
(!$this->price && $this->
loadFromDatabase
())
42
{
43
$this->price = ElementPrice::getInstance($this->
id
);
44
}
45
46
if
($this->price)
47
return
$this->price
;
48
}
49
elseif
(
$entity
===
"sku"
)
50
{
51
if
(!$this->sku && $this->
loadFromDatabase
())
52
{
53
$this->sku = ElementSku::getInstance($this->
id
);
54
}
55
56
if
($this->sku)
57
return
$this->sku
;
58
}
59
elseif
(
$entity
===
"store"
)
60
{
61
if
(!$this->store)
62
{
63
$this->store = CatalogStore::getInstance(0);
64
}
65
66
if
($this->store)
67
return
$this->store
;
68
}
69
return
parent::resolve(
$entity
);
70
}
71
79
public
function
setFields
(
array
$fields
)
80
{
81
parent::setFields(
$fields
);
82
if
(
83
is_array($this->fields)
84
&& $this->fields[
"MEASURE"
] > 0
85
)
86
{
87
$this->fields[
"MEASURE"
] =
new
ElementCatalogMeasure
($this->fields[
"MEASURE"
]);
88
}
89
}
90
97
protected
function
loadFromDatabase
()
98
{
99
if
(!isset($this->fields))
100
{
101
$this->fields =
Catalog\ProductTable::getRow
([
102
'filter'
=> [
103
'=ID'
=> $this->
id
,
104
],
105
]);
106
if
(is_array($this->fields))
107
{
108
if
($this->fields[
'MEASURE'
] > 0)
109
{
110
$this->fields[
'MEASURE'
] =
new
ElementCatalogMeasure
($this->fields[
'MEASURE'
]);
111
}
112
$this->fields[
'STORE'
] =
new
ElementCatalogStoreList
(0);
113
}
114
else
115
{
116
$this->fields = [
117
'STORE'
=>
new
ElementCatalogStoreList
(0),
118
];
119
}
120
}
121
122
return
true
;
123
}
124
}
125
126
class
ElementCatalogMeasure
extends
LazyValueLoader
127
{
133
protected
function
load
()
134
{
135
$measureList = \CCatalogMeasure::getList(
array
(),
array
(
136
"ID"
=> $this->key
137
),
false
,
false
,
array
(
"MEASURE_TITLE"
));
138
$measure = $measureList->fetch();
139
if
($measure)
140
return
$measure[
'MEASURE_TITLE'
];
141
else
142
return
""
;
143
}
144
}
145
146
class
ElementCatalogStoreList
extends
LazyValueLoader
147
{
153
protected
function
load
()
154
{
155
$storeList = \CCatalogStore::getList(
array
(),
array
(
156
"ACTIVE"
=>
"Y"
,
157
),
false
,
false
,
array
(
"ID"
,
"TITLE"
,
"ACTIVE"
));
158
$result
=
array
();
159
while
(
$ar
= $storeList->fetch())
160
{
161
$result
[] =
$ar
[
"TITLE"
];
162
}
163
return
$result
;
164
}
165
}
Bitrix\Iblock\Template\Entity\ElementCatalog
Определения
elementcatalog.php:12
Bitrix\Iblock\Template\Entity\ElementCatalog\__construct
__construct($id)
Определения
elementcatalog.php:20
Bitrix\Iblock\Template\Entity\ElementCatalog\$sku
$sku
Определения
elementcatalog.php:14
Bitrix\Iblock\Template\Entity\ElementCatalog\loadFromDatabase
loadFromDatabase()
Определения
elementcatalog.php:97
Bitrix\Iblock\Template\Entity\ElementCatalog\$price
$price
Определения
elementcatalog.php:13
Bitrix\Iblock\Template\Entity\ElementCatalog\resolve
resolve($entity)
Определения
elementcatalog.php:37
Bitrix\Iblock\Template\Entity\ElementCatalog\$store
$store
Определения
elementcatalog.php:15
Bitrix\Iblock\Template\Entity\ElementCatalog\setFields
setFields(array $fields)
Определения
elementcatalog.php:79
Bitrix\Iblock\Template\Entity\ElementCatalogMeasure
Определения
elementcatalog.php:127
Bitrix\Iblock\Template\Entity\ElementCatalogMeasure\load
load()
Определения
elementcatalog.php:133
Bitrix\Iblock\Template\Entity\ElementCatalogStoreList
Определения
elementcatalog.php:147
Bitrix\Iblock\Template\Entity\ElementCatalogStoreList\load
load()
Определения
elementcatalog.php:153
Bitrix\Iblock\Template\Entity\LazyValueLoader
Определения
base.php:171
Bitrix\Main\ORM\Data\DataManager\getRow
static getRow(array $parameters)
Определения
datamanager.php:398
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Sale\Services\Base
Определения
concreteproductrestriction.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$ar
$ar
Определения
options.php:199
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
iblock
lib
template
entity
elementcatalog.php
Создано системой
1.14.0