Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
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 =
new
ElementPrice
($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 =
new
ElementSku
($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 =
new
CatalogStore
(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\Catalog\Product\Store\DistributionStrategy\Base
Definition
base.php:21
Bitrix\Iblock\Template\Entity\CatalogStore
Definition
catalogstore.php:10
Bitrix\Iblock\Template\Entity\ElementCatalog
Definition
elementcatalog.php:12
Bitrix\Iblock\Template\Entity\ElementCatalog\__construct
__construct($id)
Definition
elementcatalog.php:20
Bitrix\Iblock\Template\Entity\ElementCatalog\$sku
$sku
Definition
elementcatalog.php:14
Bitrix\Iblock\Template\Entity\ElementCatalog\loadFromDatabase
loadFromDatabase()
Definition
elementcatalog.php:97
Bitrix\Iblock\Template\Entity\ElementCatalog\$price
$price
Definition
elementcatalog.php:13
Bitrix\Iblock\Template\Entity\ElementCatalog\resolve
resolve($entity)
Definition
elementcatalog.php:37
Bitrix\Iblock\Template\Entity\ElementCatalog\$store
$store
Definition
elementcatalog.php:15
Bitrix\Iblock\Template\Entity\ElementCatalog\setFields
setFields(array $fields)
Definition
elementcatalog.php:79
Bitrix\Iblock\Template\Entity\ElementCatalogMeasure
Definition
elementcatalog.php:127
Bitrix\Iblock\Template\Entity\ElementCatalogMeasure\load
load()
Definition
elementcatalog.php:133
Bitrix\Iblock\Template\Entity\ElementCatalogStoreList
Definition
elementcatalog.php:147
Bitrix\Iblock\Template\Entity\ElementCatalogStoreList\load
load()
Definition
elementcatalog.php:153
Bitrix\Iblock\Template\Entity\ElementPrice
Definition
elementprice.php:10
Bitrix\Iblock\Template\Entity\ElementSku
Definition
elementsku.php:10
Bitrix\Iblock\Template\Entity\LazyValueLoader
Definition
base.php:151
Bitrix\Catalog
Bitrix\Iblock\Template\Entity
Definition
base.php:7
modules
iblock
lib
template
entity
elementcatalog.php
Создано системой
1.10.0