1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
discountentity.php
См. документацию.
1
<?php
2
namespace
Bitrix\Catalog;
3
4
use Bitrix\Main,
5
Bitrix\Main\Localization\Loc,
6
Bitrix\Main\ORM,
7
Bitrix\Main\Type;
8
Loc::loadMessages(__FILE__);
9
40
41
class
DiscountEntityTable
extends
ORM\Data\DataManager
42
{
43
const
ENTITY_ELEMENT
=
'ELEMENT'
;
44
const
ENTITY_ELEMENT_PROPERTY
=
'ELEMENT_PROPERTY'
;
45
const
ENTITY_PRODUCT
=
'PRODUCT'
;
46
52
public
static
function
getTableName
()
53
{
54
return
'b_catalog_discount_entity'
;
55
}
56
62
public
static
function
getMap
()
63
{
64
return
[
65
'ID'
=>
new
ORM\Fields\IntegerField
(
'ID'
, [
66
'primary'
=>
true
,
67
'autocomplete'
=>
true
,
68
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_ID_FIELD'
)
69
]),
70
'DISCOUNT_ID'
=>
new
ORM\Fields\IntegerField
(
'DISCOUNT_ID'
, [
71
'required'
=>
true
,
72
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_DISCOUNT_ID_FIELD'
)
73
]),
74
'MODULE_ID'
=>
new
ORM\Fields\StringField
(
'MODULE_ID'
, [
75
'required'
=>
true
,
76
'validation'
=> [__CLASS__,
'validateModuleId'
],
77
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_MODULE_ID_FIELD'
)
78
]),
79
'ENTITY'
=>
new
ORM\Fields\StringField
(
'ENTITY'
, [
80
'required'
=>
true
,
81
'validation'
=> [__CLASS__,
'validateEntity'
],
82
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_ENTITY_FIELD'
)
83
]),
84
'ENTITY_ID'
=>
new
ORM\Fields\IntegerField
(
'ENTITY_ID'
, [
85
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_ENTITY_ID_FIELD'
)
86
]),
87
'ENTITY_VALUE'
=>
new
ORM\Fields\StringField
(
'ENTITY_VALUE'
, [
88
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_ENTITY_VALUE_FIELD'
)
89
]),
90
'FIELD_ENTITY'
=>
new
ORM\Fields\StringField
(
'FIELD_ENTITY'
, [
91
'required'
=>
true
,
92
'validation'
=> [__CLASS__,
'validateFieldEntity'
],
93
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_FIELD_ENTITY_FIELD'
)
94
]),
95
'FIELD_TABLE'
=>
new
ORM\Fields\StringField
(
'FIELD_TABLE'
, [
96
'required'
=>
true
,
97
'validation'
=> [__CLASS__,
'validateFieldTable'
],
98
'title'
=> Loc::getMessage(
'DISCOUNT_ENTITY_ENTITY_FIELD_TABLE_FIELD'
)
99
]),
100
'DISCOUNT'
=>
new
ORM\Fields\Relations\Reference
(
101
'DISCOUNT'
,
102
'\Bitrix\Catalog\Discount'
,
103
[
'=this.DISCOUNT_ID'
=>
'ref.ID'
]
104
)
105
];
106
}
107
113
public
static
function
validateModuleId
()
114
{
115
return
[
116
new
ORM\Fields\Validators\LengthValidator
(
null
, 50)
117
];
118
}
119
125
public
static
function
validateEntity
()
126
{
127
return
[
128
new
ORM\Fields\Validators\LengthValidator
(
null
, 255)
129
];
130
}
131
137
public
static
function
validateFieldEntity
()
138
{
139
return
[
140
new
ORM\Fields\Validators\LengthValidator
(
null
, 255)
141
];
142
}
143
149
public
static
function
validateFieldTable
()
150
{
151
return
[
152
new
ORM\Fields\Validators\LengthValidator
(
null
, 255)
153
];
154
}
155
162
public
static
function
deleteByDiscount
(
$discount
)
163
{
164
$discount
= (int)
$discount
;
165
if
(
$discount
<= 0)
166
return
;
167
$conn =
Main\Application::getConnection
();
168
$helper = $conn->getSqlHelper();
169
$conn->queryExecute(
170
'delete from '
.$helper->quote(self::getTableName()).
' where '
.$helper->quote(
'DISCOUNT_ID'
).
' = '
.
$discount
171
);
172
unset($helper, $conn);
173
}
174
183
public
static
function
getByDiscount
(
array
$discountList,
$filter
= [], $groupModule =
true
)
184
{
185
$groupModule = ($groupModule ===
true
);
186
$result
= [];
187
if
(!empty($discountList))
188
{
189
Type\Collection::normalizeArrayValuesByInt
($discountList);
190
if
(!empty($discountList))
191
{
192
if
(!is_array(
$filter
))
193
$filter
= [];
194
195
$discountRows = array_chunk($discountList, 500);
196
foreach
($discountRows as &$row)
197
{
198
$filter
[
'@DISCOUNT_ID'
] = $row;
199
$entityIterator =
self::getList
([
200
'select'
=> [
201
'DISCOUNT_ID'
,
'MODULE_ID'
,
202
'ENTITY'
,
'ENTITY_ID'
,
'ENTITY_VALUE'
,
'FIELD_ENTITY'
,
'FIELD_TABLE'
203
],
204
'filter'
=>
$filter
205
]);
206
if
($groupModule)
207
{
208
while
(
$entity
= $entityIterator->fetch())
209
{
210
unset(
$entity
[
'DISCOUNT_ID'
]);
211
$module =
$entity
[
'MODULE_ID'
];
212
$entityCode =
$entity
[
'ENTITY'
];
213
if
(!isset(
$result
[$module]))
214
$result
[$module] = [];
215
if
(!isset(
$result
[$module][$entityCode]))
216
$result
[$module][$entityCode] = [];
217
$result
[$module][$entityCode][
$entity
[
'FIELD_ENTITY'
]] =
$entity
;
218
}
219
unset($entityCode, $module);
220
}
221
else
222
{
223
while
(
$entity
= $entityIterator->fetch())
224
{
225
$entity
[
'DISCOUNT_ID'
] = (int)
$entity
[
'DISCOUNT_ID'
];
226
if
(!isset(
$result
[
$entity
[
'DISCOUNT_ID'
]]))
227
$result
[
$entity
[
'DISCOUNT_ID'
]] = [];
228
$result
[
$entity
[
'DISCOUNT_ID'
]][] =
$entity
;
229
}
230
}
231
unset(
$entity
, $entityIterator);
232
}
233
unset($row, $discountRows);
234
}
235
}
236
return
$result
;
237
}
238
}
Bitrix\Catalog\DiscountEntityTable
Определения
discountentity.php:42
Bitrix\Catalog\DiscountEntityTable\getByDiscount
static getByDiscount(array $discountList, $filter=[], $groupModule=true)
Определения
discountentity.php:183
Bitrix\Catalog\DiscountEntityTable\validateEntity
static validateEntity()
Определения
discountentity.php:125
Bitrix\Catalog\DiscountEntityTable\getMap
static getMap()
Определения
discountentity.php:62
Bitrix\Catalog\DiscountEntityTable\deleteByDiscount
static deleteByDiscount($discount)
Определения
discountentity.php:162
Bitrix\Catalog\DiscountEntityTable\validateFieldTable
static validateFieldTable()
Определения
discountentity.php:149
Bitrix\Catalog\DiscountEntityTable\validateFieldEntity
static validateFieldEntity()
Определения
discountentity.php:137
Bitrix\Catalog\DiscountEntityTable\ENTITY_ELEMENT_PROPERTY
const ENTITY_ELEMENT_PROPERTY
Определения
discountentity.php:44
Bitrix\Catalog\DiscountEntityTable\ENTITY_PRODUCT
const ENTITY_PRODUCT
Определения
discountentity.php:45
Bitrix\Catalog\DiscountEntityTable\validateModuleId
static validateModuleId()
Определения
discountentity.php:113
Bitrix\Catalog\DiscountEntityTable\ENTITY_ELEMENT
const ENTITY_ELEMENT
Определения
discountentity.php:43
Bitrix\Catalog\DiscountEntityTable\getTableName
static getTableName()
Определения
discountentity.php:52
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\ORM\Data\DataManager
Определения
datamanager.php:35
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\ORM\Data\DataManager\$entity
static $entity
Определения
datamanager.php:47
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\Relations\Reference
Определения
reference.php:26
Bitrix\Main\ORM\Fields\StringField
Определения
stringfield.php:20
Bitrix\Main\ORM\Fields\Validators\LengthValidator
Определения
lengthvalidator.php:19
Bitrix\Main\Type\Collection\normalizeArrayValuesByInt
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения
collection.php:150
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
$filter
$filter
Определения
iblock_catalog_list.php:54
$discount
$discount
Определения
waybill.php:788
bitrix
modules
catalog
lib
discountentity.php
Создано системой
1.14.0