1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
storeselector.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Controller;
4
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\StoreProductTable;
8use Bitrix\Catalog\StoreTable;
9use Bitrix\Main\Engine\Action;
10use Bitrix\Main\Engine\ActionFilter;
11use Bitrix\Main\Engine\JsonController;
12use Bitrix\Main\Error;
13
15{
16 private AccessController $accessController;
17
21 protected function init()
22 {
23 parent::init();
24
25 $this->accessController = AccessController::getCurrent();
26 }
27
28 protected function getDefaultPreFilters()
29 {
30 return array_merge(
31 parent::getDefaultPreFilters(),
32 [
35 ]
36 );
37 }
38
40 {
41 if (
42 $this->accessController->check(ActionDictionary::ACTION_CATALOG_READ)
43 || $this->accessController->check(ActionDictionary::ACTION_CATALOG_VIEW)
44 )
45 {
46 return parent::processBeforeAction($action);
47 }
48
49 $this->addError(new Error('Access denied'));
50
51 return false;
52 }
53
59 public function getProductStoresAction(int $productId): array
60 {
61 $iterator = \CIBlockElement::GetList(
62 [],
63 [
64 'ID' => $productId,
65 'ACTIVE' => 'Y',
66 'ACTIVE_DATE' => 'Y',
67 'CHECK_PERMISSIONS' => 'Y',
68 'MIN_PERMISSION' => 'R',
69 ],
70 false,
71 false,
72 ['ID', 'IBLOCK_ID', 'TYPE']
73 );
74 $element = $iterator->Fetch();
75 if (!$element)
76 {
77 return [];
78 }
79
80 $filter = [
81 '=PRODUCT_ID' => $productId,
82 ];
83
84 $accessFilter = $this->accessController->getEntityFilter(
85 ActionDictionary::ACTION_STORE_VIEW,
86 StoreProductTable::class
87 );
88 if ($accessFilter)
89 {
90 $filter[] = $accessFilter;
91 }
92
93 $storeAmounts = StoreProductTable::getList([
94 'filter' => $filter,
95 'select' => [
96 'AMOUNT',
97 'QUANTITY_RESERVED',
98 'STORE_ID',
99 'STORE_TITLE' => 'STORE.TITLE'
100 ]
101 ]);
102
103 return $storeAmounts->fetchAll();
104 }
105
106 public function createStoreAction(string $name): ?array
107 {
108 if (!$this->accessController->check(ActionDictionary::ACTION_STORE_MODIFY))
109 {
110 $this->addError(new Error('Access denied'));
111 return null;
112 }
113
114 $result = StoreTable::add([
115 'TITLE' => $name,
116 'ADDRESS' => $name,
117 ]);
118
119 if (!$result->isSuccess())
120 {
121 $this->addErrors($result->getErrors());
122
123 return [];
124 }
125
126 return [
127 'id' => $result->getId(),
128 ];
129 }
130}
createStoreAction(string $name)
Определения storeselector.php:106
processBeforeAction(Action $action)
Определения storeselector.php:39
getProductStoresAction(int $productId)
Определения storeselector.php:59
addError(Error $error)
Определения controller.php:1070
addErrors(array $errors)
Определения controller.php:1083
Определения error.php:15
static getList(array $parameters=array())
Определения datamanager.php:431
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$filter
Определения iblock_catalog_list.php:54
$name
Определения menu_edit.php:35
$action
Определения file_dialog.php:21
$iterator
Определения yandex_run.php:610