Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
productgroupaccess.php
1
<?php
2
namespace
Bitrix\Catalog
;
3
4
use
Bitrix\Main
,
5
Bitrix\Main\Localization\Loc
;
6
Loc::loadMessages
(__FILE__);
7
37
class
ProductGroupAccessTable
extends
Main\Entity\DataManager
38
{
39
const
ACCESS_LENGTH_HOUR
=
'H'
;
40
const
ACCESS_LENGTH_DAY
=
'D'
;
41
const
ACCESS_LENGTH_WEEK
=
'W'
;
42
const
ACCESS_LENGTH_MONTH
=
'M'
;
43
const
ACCESS_LENGTH_QUART
=
'Q'
;
44
const
ACCESS_LENGTH_SEMIYEAR
=
'S'
;
45
const
ACCESS_LENGTH_YEAR
=
'Y'
;
46
52
public
static
function
getTableName
()
53
{
54
return
'b_catalog_product2group'
;
55
}
56
62
public
static
function
getMap
()
63
{
64
return
array(
65
'ID'
=>
new
Main\
Entity
\
IntegerField
(
'ID'
, array(
66
'primary'
=>
true
,
67
'autocomplete'
=>
true
,
68
'title'
=>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ID_FIELD'
)
69
)),
70
'PRODUCT_ID'
=>
new
Main\
Entity
\
IntegerField
(
'PRODUCT_ID'
, array(
71
'required'
=>
true
,
72
'title'
=>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_PRODUCT_ID_FIELD'
)
73
)),
74
'GROUP_ID'
=>
new
Main\
Entity
\
IntegerField
(
'GROUP_ID'
, array(
75
'required'
=>
true
,
76
'title'
=>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_GROUP_ID_FIELD'
)
77
)),
78
'ACCESS_LENGTH'
=>
new
Main\
Entity
\
IntegerField
(
'ACCESS_LENGTH'
, array(
79
'required'
=>
true
,
80
'title'
=>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_FIELD'
)
81
)),
82
'ACCESS_LENGTH_TYPE'
=>
new
Main\
Entity
\
EnumField
(
'ACCESS_LENGTH_TYPE'
, array(
83
'required'
=>
true
,
84
'values'
=> static::getAccessPeriods(
false
),
85
'default_value'
=> self::ACCESS_LENGTH_DAY,
86
'title'
=>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_TYPE_FIELD'
)
87
)),
88
'PRODUCT'
=>
new
Main\
Entity
\ReferenceField(
89
'PRODUCT'
,
90
'\Bitrix\Catalog\Product'
,
91
array(
'=this.PRODUCT_ID'
=>
'ref.ID'
),
92
array(
'join_type'
=>
'LEFT'
)
93
)
94
);
95
}
96
103
public
static
function
getAccessPeriods
($descr =
false
)
104
{
105
if
($descr)
106
{
107
return
array(
108
self::ACCESS_LENGTH_HOUR =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_HOUR'
),
109
self::ACCESS_LENGTH_DAY =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_DAY'
),
110
self::ACCESS_LENGTH_WEEK =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_WEEK'
),
111
self::ACCESS_LENGTH_MONTH =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_MONTH'
),
112
self::ACCESS_LENGTH_QUART =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_QUART'
),
113
self::ACCESS_LENGTH_SEMIYEAR =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_SEMIYEAR'
),
114
self::ACCESS_LENGTH_YEAR =>
Loc::getMessage
(
'PRODUCTGROUPACCESS_ENTITY_ACCESS_LENGTH_YEAR'
)
115
);
116
}
117
return
array(
118
self::ACCESS_LENGTH_HOUR,
119
self::ACCESS_LENGTH_DAY,
120
self::ACCESS_LENGTH_WEEK,
121
self::ACCESS_LENGTH_MONTH,
122
self::ACCESS_LENGTH_QUART,
123
self::ACCESS_LENGTH_SEMIYEAR,
124
self::ACCESS_LENGTH_YEAR
125
);
126
}
127
135
public
static
function
deleteByProduct
($id)
136
{
137
$id = (int)$id;
138
if
($id <= 0)
139
return
;
140
141
$conn = Main\Application::getConnection();
142
$helper = $conn->getSqlHelper();
143
$conn->queryExecute(
144
'delete from '
.$helper->quote(self::getTableName()).
' where '
.$helper->quote(
'PRODUCT_ID'
).
' = '
.$id
145
);
146
unset($helper, $conn);
147
}
148
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Catalog\ProductGroupAccessTable
Definition
productgroupaccess.php:38
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_YEAR
const ACCESS_LENGTH_YEAR
Definition
productgroupaccess.php:45
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_HOUR
const ACCESS_LENGTH_HOUR
Definition
productgroupaccess.php:39
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_SEMIYEAR
const ACCESS_LENGTH_SEMIYEAR
Definition
productgroupaccess.php:44
Bitrix\Catalog\ProductGroupAccessTable\getMap
static getMap()
Definition
productgroupaccess.php:62
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_QUART
const ACCESS_LENGTH_QUART
Definition
productgroupaccess.php:43
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_DAY
const ACCESS_LENGTH_DAY
Definition
productgroupaccess.php:40
Bitrix\Catalog\ProductGroupAccessTable\deleteByProduct
static deleteByProduct($id)
Definition
productgroupaccess.php:135
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_WEEK
const ACCESS_LENGTH_WEEK
Definition
productgroupaccess.php:41
Bitrix\Catalog\ProductGroupAccessTable\getAccessPeriods
static getAccessPeriods($descr=false)
Definition
productgroupaccess.php:103
Bitrix\Catalog\ProductGroupAccessTable\ACCESS_LENGTH_MONTH
const ACCESS_LENGTH_MONTH
Definition
productgroupaccess.php:42
Bitrix\Catalog\ProductGroupAccessTable\getTableName
static getTableName()
Definition
productgroupaccess.php:52
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\Fields\EnumField
Definition
enumfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Catalog
Bitrix\Main
modules
catalog
lib
productgroupaccess.php
Создано системой
1.10.0