1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pricefieldassembler.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Grid\Row\Assembler;
4
5use Bitrix\Catalog\Grid\Column\PriceProvider;
6use Bitrix\Main\Grid\Row\FieldAssembler;
7use Bitrix\Main\Loader;
8use CCurrencyLang;
9
11{
12 private bool $isCurrencyIncluded;
13
14 public function __construct(array $columnIds)
15 {
16 parent::__construct($columnIds);
17
18 $this->isCurrencyIncluded = Loader::includeModule('currency');
19 }
20
33 protected function getCurrencyColumnId(string $priceColumnId): ?string
34 {
35 $priceTypeId = PriceProvider::parsePriceTypeId($priceColumnId);
36 if (isset($priceTypeId))
37 {
38 return PriceProvider::getCurrencyPriceTypeId($priceTypeId);
39 }
40
41 return null;
42 }
43
44 final protected function prepareRow(array $row): array
45 {
46 if (empty($this->getColumnIds()))
47 {
48 return $row;
49 }
50
51 foreach ($this->getColumnIds() as $priceColumnId)
52 {
53 $currencyColumnId = $this->getCurrencyColumnId($priceColumnId);
54 if (isset($currencyColumnId))
55 {
56 $priceValue = $row['data'][$priceColumnId] ?? null;
57 $currencyValue = $row['data'][$currencyColumnId] ?? null;
58
59 if ($this->isCurrencyIncluded)
60 {
61 $row['columns'][$priceColumnId] = CCurrencyLang::CurrencyFormat(
62 $priceValue,
63 $currencyValue
64 );
65 }
66 else
67 {
68 $row['columns'][$priceColumnId] = $priceValue;
69 }
70
71 $row['data'][$priceColumnId] = [
72 'PRICE' => [
73 'NAME' => 'PRICE',
74 'VALUE' => $priceValue,
75 ],
76 'CURRENCY' => [
77 'NAME' => 'CURRENCY',
78 'VALUE' => $currencyValue,
79 ],
80 ];
81 }
82 }
83
84 return $row;
85 }
86}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804