Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
changepricesactionsitem.php
1<?php
2
4
12
18final class ChangePricesActionsItem implements Action
19{
20 private int $iblockId;
21 private ProductRightsChecker $rights;
22
23 public function __construct(int $iblockId, ProductRightsChecker $rights)
24 {
25 $this->iblockId = $iblockId;
26 $this->rights = $rights;
27 }
28
32 public static function getId(): string
33 {
34 return 'change_price';
35 }
36
40 public function processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter): ?Result
41 {
42 if (empty($request->get('chprice_value_changing_price')))
43 {
44 return null;
45 }
46
47 if (!$this->rights->canEditPrices())
48 {
49 return null;
50 }
51
52 $ids = $request->getPost('ID');
53 if (!is_array($ids))
54 {
55 return null;
56 }
57
58 [$elementIds, $sectionIds] = RowType::parseIndexList($ids);
59 if (empty($elementIds) && empty($sectionIds))
60 {
61 return null;
62 }
63
64 $changerParams = [
65 'PRICE_TYPE' => $request->get('chprice_id_price_type'),
66 'UNITS' => $request->get('chprice_units'),
67 'FORMAT_RESULTS' => $request->get('chprice_format_result'),
68 'INITIAL_PRICE_TYPE' => $request->get('chprice_initial_price_type'),
69 'RESULT_MASK' => $request->get('chprice_result_mask'),
70 'DIFFERENCE_VALUE' => $request->get('chprice_difference_value'),
71 'VALUE_CHANGING' => $request->get('chprice_value_changing_price'),
72 ];
73
74 $changePrice = new IblockPriceChanger($changerParams, $this->iblockId);
75
76 return $changePrice->updatePrices([
77 'SECTIONS' => $sectionIds,
78 'ELEMENTS' => $elementIds,
79 ]);
80 }
81
85 public function getControl(): ?array
86 {
87 return null;
88 }
89}
processRequest(HttpRequest $request, bool $isSelectedAllRows, ?Filter $filter)
__construct(int $iblockId, ProductRightsChecker $rights)
static parseIndexList(array $ids)
Definition rowtype.php:52