Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
priceprovider.php
1
<?php
2
3
namespace
Bitrix\Catalog\Grid\Column
;
4
5
use
Bitrix\Main\Grid
;
6
use
Bitrix\Catalog
;
7
use
Bitrix\Catalog\Access
;
8
9
class
PriceProvider
extends
CatalogProvider
10
{
11
private
const
PREFIX_PRICE_COLUMN_ID =
'PRICE_'
;
12
private
const
PREFIX_CURRENCY_COLUMN_ID=
'CURRENCY_'
;
13
14
public
function
prepareColumns
(): array
15
{
16
$result = [];
17
18
$editable =
false
;
19
foreach
(Catalog\
GroupTable::getTypeList
() as $priceType)
20
{
21
$priceTypeId = (int)$priceType[
'ID'
];
22
$columnId = static::getPriceTypeColumnId($priceTypeId);
23
24
$result[$columnId] = [
25
'type'
=> Grid\Column\Type::MONEY,
26
'name'
=> $priceType[
'NAME_LANG'
] ?? $priceType[
'NAME'
],
27
'necessary'
=>
false
,
28
'editable'
=> $editable ?:
new
Grid\Column\Editable\MoneyConfig
($columnId),
29
'multiple'
=>
false
,
30
'sort'
=>
'SCALED_PRICE_'
. $priceTypeId,
31
'align'
=>
'right'
,
32
'select'
=> [
33
self::getPriceTypeColumnId
($priceTypeId),
34
self::getCurrencyPriceTypeId
($priceTypeId),
35
],
36
];
37
}
38
39
return
$this->
createColumns
($result);
40
}
41
42
public
static
function
parsePriceTypeId
(
string
$columnId): ?int
43
{
44
$prefix = preg_quote(self::PREFIX_PRICE_COLUMN_ID);
45
$re =
"/^{$prefix}(\d+)$/"
;
46
47
if
(preg_match($re, $columnId, $m))
48
{
49
return
(
int
)$m[1];
50
}
51
52
return
null
;
53
}
54
55
public
static
function
getPriceTypeColumnId
(
int
$priceTypeId): string
56
{
57
return
self::PREFIX_PRICE_COLUMN_ID . $priceTypeId;
58
}
59
60
public
static
function
getCurrencyPriceTypeId
(
int
$priceTypeId)
61
{
62
return
self::PREFIX_CURRENCY_COLUMN_ID . $priceTypeId;
63
}
64
65
protected
function
allowPriceEdit
(): bool
66
{
67
return
68
$this->
allowProductEdit
()
69
&& $this->accessController->check(
Access
\
ActionDictionary::ACTION_PRICE_EDIT
)
70
;
71
}
72
}
Bitrix\Catalog\Access\ActionDictionary\ACTION_PRICE_EDIT
const ACTION_PRICE_EDIT
Definition
ActionDictionary.php:66
Bitrix\Catalog\Grid\Column\CatalogProvider
Definition
catalogprovider.php:12
Bitrix\Catalog\Grid\Column\CatalogProvider\allowProductEdit
allowProductEdit()
Definition
catalogprovider.php:22
Bitrix\Catalog\Grid\Column\PriceProvider
Definition
priceprovider.php:10
Bitrix\Catalog\Grid\Column\PriceProvider\getPriceTypeColumnId
static getPriceTypeColumnId(int $priceTypeId)
Definition
priceprovider.php:55
Bitrix\Catalog\Grid\Column\PriceProvider\getCurrencyPriceTypeId
static getCurrencyPriceTypeId(int $priceTypeId)
Definition
priceprovider.php:60
Bitrix\Catalog\Grid\Column\PriceProvider\allowPriceEdit
allowPriceEdit()
Definition
priceprovider.php:65
Bitrix\Catalog\Grid\Column\PriceProvider\prepareColumns
prepareColumns()
Definition
priceprovider.php:14
Bitrix\Catalog\Grid\Column\PriceProvider\parsePriceTypeId
static parsePriceTypeId(string $columnId)
Definition
priceprovider.php:42
Bitrix\Catalog\GroupTable\getTypeList
static getTypeList()
Definition
group.php:260
Bitrix\Main\Grid\Column\DataProvider\createColumns
createColumns(array $columns)
Definition
dataprovider.php:61
Bitrix\Main\Grid\Column\Editable\MoneyConfig
Definition
moneyconfig.php:13
Bitrix\Rest\Engine\Access
Definition
access.php:19
Bitrix\Catalog\Access
Definition
AccessController.php:9
Bitrix\Catalog\Grid\Column
Definition
barcodeprovider.php:3
Bitrix\Catalog
Bitrix\Main\Grid
modules
catalog
lib
grid
column
priceprovider.php
Создано системой
1.10.0