Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
converttoproductitem.php
1
<?php
2
3
namespace
Bitrix\Catalog\Grid\Row\Actions\Item
;
4
5
use
Bitrix\Catalog\Grid\ProductAction
;
6
use
Bitrix\Main\HttpRequest
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Result
;
9
use CUtil;
10
11
final
class
ConvertToProductItem
extends
BaseItem
12
{
13
public
static
function
getId
(): ?string
14
{
15
return
'convert_to_product'
;
16
}
17
18
protected
function
getText
(): string
19
{
20
return
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_PRODUCT_TEXT'
);
21
}
22
23
public
function
getControl
(array $rawFields): ?array
24
{
25
$id = (int)($rawFields[
'ID'
] ?? 0);
26
if
($id <= 0)
27
{
28
return
null
;
29
}
30
31
$actionId =
self::getId
();
32
$data = CUtil::PhpToJSObject([
33
'id'
=> $id,
34
]);
35
$confirmMessage = \CUtil::JSEscape(
36
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_PRODUCT_CONFIRM_MESSAGE_MSGVER_1'
)
37
);
38
39
$confirmButtonMessage = \CUtil::JSEscape(
40
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_PRODUCT_CONFIRM_BUTTON'
)
41
);
42
$backButtonMessage = \CUtil::JSEscape(
43
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_PRODUCT_BACK_BUTTON'
)
44
);
45
46
$this->onclick =
"IblockGridInstance.sendSmallPopupWithConfirm('{$actionId}', {$data}, '{$confirmMessage}', '{$confirmButtonMessage}', '{$backButtonMessage}')"
;
47
48
return
parent::getControl($rawFields);
49
}
50
51
public
function
processRequest
(
HttpRequest
$request): ?
Result
52
{
53
$id = $request->getPost(
'id'
);
54
if
(empty($id) || !is_numeric($id))
55
{
56
return
null
;
57
}
58
$id = (int)$id;
59
60
return
ProductAction::convertToProductElementList
($this->
getIblockId
(), [$id]);
61
}
62
}
Bitrix\Catalog\Grid\ProductAction
Definition
productaction.php:16
Bitrix\Catalog\Grid\ProductAction\convertToProductElementList
static convertToProductElementList(int $iblockId, array $elementIds)
Definition
productaction.php:392
Bitrix\Catalog\Grid\Row\Actions\Item\BaseItem
Definition
baseitem.php:8
Bitrix\Catalog\Grid\Row\Actions\Item\BaseItem\getIblockId
getIblockId()
Definition
baseitem.php:18
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem
Definition
converttoproductitem.php:12
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem\getControl
getControl(array $rawFields)
Definition
converttoproductitem.php:23
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem\getText
getText()
Definition
converttoproductitem.php:18
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem\getId
static getId()
Definition
converttoproductitem.php:13
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToProductItem\processRequest
processRequest(HttpRequest $request)
Definition
converttoproductitem.php:51
Bitrix\Main\HttpRequest
Definition
httprequest.php:20
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Catalog\Grid\Row\Actions\Item
Definition
baseitem.php:3
modules
catalog
lib
grid
row
actions
item
converttoproductitem.php
Создано системой
1.10.0