1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
storeselector.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Catalog\Controller;
4
5
use Bitrix\Catalog\Access\AccessController;
6
use Bitrix\Catalog\Access\ActionDictionary;
7
use Bitrix\Catalog\StoreProductTable;
8
use Bitrix\Catalog\StoreTable;
9
use Bitrix\Main\Engine\Action;
10
use Bitrix\Main\Engine\ActionFilter;
11
use Bitrix\Main\Engine\JsonController;
12
use Bitrix\Main\Error;
13
14
class
StoreSelector
extends
JsonController
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
[
33
new
ActionFilter
\
HttpMethod
([
ActionFilter
\
HttpMethod::METHOD_POST
]),
34
new
ActionFilter
\
Scope
(
ActionFilter
\
Scope::AJAX
),
35
]
36
);
37
}
38
39
protected
function
processBeforeAction
(
Action
$action
)
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
}
Bitrix\Catalog\Access\AccessController
Определения
AccessController.php:29
Bitrix\Catalog\Controller\StoreSelector
Определения
storeselector.php:15
Bitrix\Catalog\Controller\StoreSelector\createStoreAction
createStoreAction(string $name)
Определения
storeselector.php:106
Bitrix\Catalog\Controller\StoreSelector\getDefaultPreFilters
getDefaultPreFilters()
Определения
storeselector.php:28
Bitrix\Catalog\Controller\StoreSelector\init
init()
Определения
storeselector.php:21
Bitrix\Catalog\Controller\StoreSelector\processBeforeAction
processBeforeAction(Action $action)
Определения
storeselector.php:39
Bitrix\Catalog\Controller\StoreSelector\getProductStoresAction
getProductStoresAction(int $productId)
Определения
storeselector.php:59
Bitrix\Main\Engine\ActionFilter\HttpMethod
Определения
httpmethod.php:13
Bitrix\Main\Engine\ActionFilter\HttpMethod\METHOD_POST
const METHOD_POST
Определения
httpmethod.php:15
Bitrix\Main\Engine\ActionFilter\Scope
Определения
scope.php:12
Bitrix\Main\Engine\ActionFilter\Scope\AJAX
const AJAX
Определения
scope.php:13
Bitrix\Main\Engine\Action
Определения
action.php:17
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Определения
controller.php:1070
Bitrix\Main\Engine\Controller\addErrors
addErrors(array $errors)
Определения
controller.php:1083
Bitrix\Main\Engine\JsonController
Определения
jsoncontroller.php:9
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
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
$filter
$filter
Определения
iblock_catalog_list.php:54
$name
$name
Определения
menu_edit.php:35
Bitrix\Main\Engine\ActionFilter
$action
$action
Определения
file_dialog.php:21
$iterator
$iterator
Определения
yandex_run.php:610
bitrix
modules
catalog
lib
controller
storeselector.php
Создано системой
1.14.0