1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
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
Определения
ActionDictionary.php:66
Bitrix\Catalog\Grid\Column\CatalogProvider
Определения
catalogprovider.php:12
Bitrix\Catalog\Grid\Column\CatalogProvider\allowProductEdit
allowProductEdit()
Определения
catalogprovider.php:22
Bitrix\Catalog\Grid\Column\PriceProvider
Определения
priceprovider.php:10
Bitrix\Catalog\Grid\Column\PriceProvider\getPriceTypeColumnId
static getPriceTypeColumnId(int $priceTypeId)
Определения
priceprovider.php:55
Bitrix\Catalog\Grid\Column\PriceProvider\getCurrencyPriceTypeId
static getCurrencyPriceTypeId(int $priceTypeId)
Определения
priceprovider.php:60
Bitrix\Catalog\Grid\Column\PriceProvider\allowPriceEdit
allowPriceEdit()
Определения
priceprovider.php:65
Bitrix\Catalog\Grid\Column\PriceProvider\prepareColumns
prepareColumns()
Определения
priceprovider.php:14
Bitrix\Catalog\Grid\Column\PriceProvider\parsePriceTypeId
static parsePriceTypeId(string $columnId)
Определения
priceprovider.php:42
Bitrix\Catalog\GroupTable\getTypeList
static getTypeList()
Определения
group.php:273
Bitrix\Main\Grid\Column\Editable\MoneyConfig
Определения
moneyconfig.php:13
Bitrix\Main\Grid\Column\Type\MONEY
const MONEY
Определения
type.php:20
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
Bitrix\Catalog\Access
Определения
AccessController.php:9
Bitrix\Catalog
bitrix
modules
catalog
lib
grid
column
priceprovider.php
Создано системой
1.14.0