Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
price.php
1
<?php
2
namespace
Bitrix\Catalog
;
3
4
use
Bitrix\Main
,
5
Bitrix\Main\Localization\Loc
;
6
Loc::loadMessages
(__FILE__);
7
42
class
PriceTable
extends
Main\ORM\Data\DataManager
43
{
49
public
static
function
getTableName
()
50
{
51
return
'b_catalog_price'
;
52
}
53
59
public
static
function
getMap
()
60
{
61
return
array(
62
'ID'
=>
new
Main\
Entity
\
IntegerField
(
'ID'
, array(
63
'primary'
=>
true
,
64
'autocomplete'
=>
true
,
65
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_ID_FIELD'
)
66
)),
67
'PRODUCT_ID'
=>
new
Main\
Entity
\
IntegerField
(
'PRODUCT_ID'
, array(
68
'required'
=>
true
,
69
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_PRODUCT_ID_FIELD'
)
70
)),
71
'EXTRA_ID'
=>
new
Main\
Entity
\
IntegerField
(
'EXTRA_ID'
, array(
72
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_EXTRA_ID_FIELD'
)
73
)),
74
'CATALOG_GROUP_ID'
=>
new
Main\
Entity
\
IntegerField
(
'CATALOG_GROUP_ID'
, array(
75
'required'
=>
true
,
76
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_CATALOG_GROUP_ID_FIELD'
)
77
)),
78
'PRICE'
=>
new
Main\
Entity
\
FloatField
(
'PRICE'
, array(
79
'required'
=>
true
,
80
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_PRICE_FIELD'
)
81
)),
82
'CURRENCY'
=>
new
Main\
Entity
\
StringField
(
'CURRENCY'
, array(
83
'required'
=>
true
,
84
'validation'
=> array(__CLASS__,
'validateCurrency'
),
85
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_CURRENCY_FIELD'
)
86
)),
87
'TIMESTAMP_X'
=>
new
Main\
Entity
\
DatetimeField
(
'TIMESTAMP_X'
, array(
88
'default_value'
=>
function
(){
return
new
Main\Type\DateTime
(); },
89
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_TIMESTAMP_X_FIELD'
)
90
)),
91
'QUANTITY_FROM'
=>
new
Main\Entity\IntegerField(
'QUANTITY_FROM'
, array(
92
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_QUANTITY_FROM_FIELD'
)
93
)),
94
'QUANTITY_TO'
=>
new
Main\Entity\IntegerField(
'QUANTITY_TO'
, array(
95
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_QUANTITY_TO_FIELD'
)
96
)),
97
'TMP_ID'
=>
new
Main\Entity\StringField(
'TMP_ID'
, array(
98
'validation'
=> array(__CLASS__,
'validateTmpId'
),
99
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_TMP_ID_FIELD'
)
100
)),
101
'PRICE_SCALE'
=>
new
Main\Entity\FloatField(
'PRICE_SCALE'
, array(
102
'required'
=>
true
,
103
'title'
=>
Loc::getMessage
(
'PRICE_ENTITY_PRICE_SCALE_FIELD'
)
104
)),
105
'CATALOG_GROUP'
=>
new
Main\Entity\ReferenceField(
106
'CATALOG_GROUP'
,
107
'\Bitrix\Catalog\Group'
,
108
array(
'=this.CATALOG_GROUP_ID'
=>
'ref.ID'
)
109
),
110
'ELEMENT'
=>
new
Main\Entity\ReferenceField(
111
'ELEMENT'
,
112
'\Bitrix\Iblock\Element'
,
113
array(
'=this.PRODUCT_ID'
=>
'ref.ID'
),
114
array(
'join_type'
=>
'LEFT'
)
115
),
116
'PRODUCT'
=>
new
Main\Entity\ReferenceField(
117
'PRODUCT'
,
118
'\Bitrix\Catalog\Product'
,
119
array(
'=this.PRODUCT_ID'
=>
'ref.ID'
),
120
array(
'join_type'
=>
'LEFT'
)
121
),
122
);
123
}
129
public
static
function
validateCurrency
()
130
{
131
return
array(
132
new
Main\
Entity
\Validator\Length(
null
, 3),
133
);
134
}
140
public
static
function
validateTmpId
()
141
{
142
return
array(
143
new
Main\
Entity
\Validator\Length(
null
, 40),
144
);
145
}
146
154
public
static
function
deleteByProduct
($id)
155
{
156
$id = (int)$id;
157
if
($id <= 0)
158
return
;
159
160
$conn = Main\Application::getConnection();
161
$helper = $conn->getSqlHelper();
162
$conn->queryExecute(
163
'delete from '
.$helper->quote(self::getTableName()).
' where '
.$helper->quote(
'PRODUCT_ID'
).
' = '
.$id
164
);
165
unset($helper, $conn);
166
}
167
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Catalog\PriceTable
Definition
price.php:43
Bitrix\Catalog\PriceTable\getMap
static getMap()
Definition
price.php:59
Bitrix\Catalog\PriceTable\deleteByProduct
static deleteByProduct($id)
Definition
price.php:154
Bitrix\Catalog\PriceTable\validateCurrency
static validateCurrency()
Definition
price.php:129
Bitrix\Catalog\PriceTable\validateTmpId
static validateTmpId()
Definition
price.php:140
Bitrix\Catalog\PriceTable\getTableName
static getTableName()
Definition
price.php:49
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\FloatField
Definition
floatfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Catalog
Bitrix\Main
modules
catalog
lib
price.php
Создано системой
1.10.0