1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
productrowactionsprovider.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Grid\Row\Actions;
4
5use Bitrix\Catalog\Grid\Access\ProductRightsChecker;
6use Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem;
7use Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem;
8use Bitrix\Catalog\Grid\Settings\ProductSettings;
9use Bitrix\Catalog\ProductTable;
10use Bitrix\Iblock\Grid\Row\Actions\ElementRowActionsProvider;
11use Bitrix\Main\Loader;
12
13Loader::requireModule('iblock');
14
20{
21 public function __construct(ProductSettings $settings, ProductRightsChecker $rights)
22 {
23 parent::__construct($settings, $rights);
24 }
25
26 public function prepareActions(): array
27 {
28 $elementActions = parent::prepareActions();
29
30 if ($this->getIblockRightsChecker()->canEditElements())
31 {
32 $elementActions[] = new ConvertToServiceItem($this->getIblockId(), $this->getIblockRightsChecker());
33 $elementActions[] = new ConvertToProductItem($this->getIblockId(), $this->getIblockRightsChecker());
34 }
35
36 return $elementActions;
37 }
38
39 public function prepareControls(array $rawFields): array
40 {
41 $controls = parent::prepareControls($rawFields);
42
43 $isSection = isset($rawFields['ROW_TYPE']) && $rawFields['ROW_TYPE'] === 'S';
44 if (!$isSection)
45 {
46 $id = (int)($rawFields['ID'] ?? 0);
47 if ($id > 0)
48 {
49 $additionalItems = [];
50
51 $productType = (int)($rawFields['TYPE'] ?? $this->getProductType($id) ?? 0);
52 if ($productType === ProductTable::TYPE_SERVICE)
53 {
54 $additionalItems[] = $this->getActionById(ConvertToProductItem::getId());
55 }
56 if ($productType === ProductTable::TYPE_PRODUCT)
57 {
58 $additionalItems[] = $this->getActionById(ConvertToServiceItem::getId());
59 }
60
61 foreach ($additionalItems as $item)
62 {
66 $control = isset($item) ? $item->getControl($rawFields) : null;
67 if (isset($control))
68 {
69 $controls[] = $control;
70 }
71 }
72 }
73 }
74
75 return $controls;
76 }
77
78 private function getProductType(int $productId): ?int
79 {
81 'select' => [
82 'TYPE'
83 ],
84 'filter' => [
85 '=ID' => $productId,
86 ],
87 ]);
88 if ($row)
89 {
90 return (int)$row['TYPE'];
91 }
92
93 return null;
94 }
95}
__construct(ProductSettings $settings, ProductRightsChecker $rights)
Определения productrowactionsprovider.php:21
const TYPE_SERVICE
Определения product.php:76
const TYPE_PRODUCT
Определения product.php:70
static getRow(array $parameters)
Определения datamanager.php:398
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$control
Определения iblock_catalog_edit.php:61