1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
discountmodule.php
См. документацию.
1
<?php
2
namespace
Bitrix\Sale\Internals;
3
4
use Bitrix\Main;
5
use Bitrix\Main\Application;
6
use Bitrix\Main\Localization\Loc;
7
8
Loc::loadMessages(__FILE__);
9
35
36
class
DiscountModuleTable
extends
Main\Entity\DataManager
37
{
43
public
static
function
getTableName
()
44
{
45
return
'b_sale_discount_module'
;
46
}
47
53
public
static
function
getMap
()
54
{
55
return
array
(
56
'ID'
=>
new
Main
\
Entity
\
IntegerField
(
'ID'
,
array
(
57
'primary'
=>
true
,
58
'autocomplete'
=>
true
,
59
'title'
=> Loc::getMessage(
'DISCOUNT_MODULE_ENTITY_ID_FIELD'
)
60
)),
61
'DISCOUNT_ID'
=>
new
Main
\
Entity
\
IntegerField
(
'DISCOUNT_ID'
,
array
(
62
'required'
=>
true
,
63
'title'
=> Loc::getMessage(
'DISCOUNT_MODULE_ENTITY_DISCOUNT_ID_FIELD'
)
64
)),
65
'MODULE_ID'
=>
new
Main
\
Entity
\
StringField
(
'MODULE_ID'
,
array
(
66
'required'
=>
true
,
67
'validation'
=>
array
(__CLASS__,
'validateModuleId'
),
68
'title'
=> Loc::getMessage(
'DISCOUNT_MODULE_ENTITY_MODULE_ID_FIELD'
)
69
)),
70
);
71
}
72
77
public
static
function
validateModuleId
()
78
{
79
return
array
(
80
new
Main
\
Entity
\
Validator
\Length(
null
, 50),
81
);
82
}
83
90
public
static
function
deleteByDiscount
(
$discount
)
91
{
92
$discount
= (int)
$discount
;
93
if
(
$discount
<= 0)
94
return
;
95
$conn = Application::getConnection();
96
$helper = $conn->getSqlHelper();
97
$conn->queryExecute(
98
'delete from '
.$helper->quote(self::getTableName()).
' where '
.$helper->quote(
'DISCOUNT_ID'
).
' = '
.
$discount
99
);
100
}
101
110
public
static
function
updateByDiscount
(
$discount
, $moduleList, $clear)
111
{
112
$discount
= (int)
$discount
;
113
if
(
$discount
<= 0)
114
return
false
;
115
$clear = ($clear ===
true
);
116
if
($clear)
117
{
118
self::deleteByDiscount
(
$discount
);
119
}
120
if
(!empty($moduleList) && is_array($moduleList))
121
{
122
foreach
($moduleList as &$module)
123
{
124
$fields
=
array
(
125
'DISCOUNT_ID'
=>
$discount
,
126
'MODULE_ID'
=> $module
127
);
128
$result
= self::add(
$fields
);
129
}
130
unset($module);
131
}
132
return
true
;
133
}
134
142
public
static
function
getByDiscount
($discountList,
$filter
=
array
())
143
{
144
$result
=
array
();
145
if
(!empty($discountList) && is_array($discountList))
146
{
147
Main\Type\Collection::normalizeArrayValuesByInt
($discountList);
148
if
(!empty($discountList))
149
{
150
if
(!is_array(
$filter
))
151
$filter
=
array
();
152
153
$discountRows = array_chunk($discountList, 500);
154
foreach
($discountRows as &$row)
155
{
156
$filter
[
'@DISCOUNT_ID'
] = $row;
157
158
$moduleIterator = self::getList(
array
(
159
'select'
=>
array
(
'DISCOUNT_ID'
,
'MODULE_ID'
),
160
'filter'
=>
$filter
161
));
162
while
($module = $moduleIterator->fetch())
163
{
164
$module[
'DISCOUNT_ID'
] = (int)$module[
'DISCOUNT_ID'
];
165
if
(!isset(
$result
[$module[
'DISCOUNT_ID'
]]))
166
$result
[$module[
'DISCOUNT_ID'
]] =
array
();
167
$result
[$module[
'DISCOUNT_ID'
]][] = $module[
'MODULE_ID'
];
168
}
169
unset($module, $moduleIterator);
170
}
171
unset($row, $discountRows);
172
}
173
}
174
return
$result
;
175
}
176
}
Bitrix\Catalog\DiscountModuleTable
Определения
discountmodule.php:35
Bitrix\Catalog\DiscountModuleTable\deleteByDiscount
static deleteByDiscount($discount)
Определения
discountmodule.php:88
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Определения
stringfield.php:20
Bitrix\Main\ORM\Fields\Validators\Validator
Определения
validator.php:18
Bitrix\Main\Type\Collection\normalizeArrayValuesByInt
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения
collection.php:150
Bitrix\Sale\Internals\DiscountModuleTable\getMap
static getMap()
Определения
discountmodule.php:53
Bitrix\Sale\Internals\DiscountModuleTable\deleteByDiscount
static deleteByDiscount($discount)
Определения
discountmodule.php:90
Bitrix\Sale\Internals\DiscountModuleTable\getByDiscount
static getByDiscount($discountList, $filter=array())
Определения
discountmodule.php:142
Bitrix\Sale\Internals\DiscountModuleTable\updateByDiscount
static updateByDiscount($discount, $moduleList, $clear)
Определения
discountmodule.php:110
Bitrix\Sale\Internals\DiscountModuleTable\validateModuleId
static validateModuleId()
Определения
discountmodule.php:77
Bitrix\Sale\Internals\DiscountModuleTable\getTableName
static getTableName()
Определения
discountmodule.php:43
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
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
$discount
$discount
Определения
waybill.php:788
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
internals
discountmodule.php
Создано системой
1.14.0