1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
settings.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Catalog\Integration\AI
;
4
5
use Bitrix\AI\Context;
6
use Bitrix\AI\Engine;
7
use Bitrix\AI\Tuning;
8
use
Bitrix\Main\Entity
;
9
use
Bitrix\Main\Loader
;
10
use
Bitrix\Main\Localization\Loc
;
11
12
class
Settings
13
{
14
private
const
TEXT_CATEGORY =
'text'
;
15
private
const
TUNING_CODE_TEXT_PRODUCT_CARD =
'catalog_product_card_allow_text_generate'
;
16
17
public
static
function
isTextProductCardAvailable
(): bool
18
{
19
if
(!self::checkEngineAvailable(self::TEXT_CATEGORY))
20
{
21
return
false
;
22
}
23
24
$item = (
new
Tuning\Manager())->getItem(self::TUNING_CODE_TEXT_PRODUCT_CARD);
25
26
return
$item ? $item->getValue() :
true
;
27
}
28
29
private
static
function
checkEngineAvailable(
string
$type
): bool
30
{
31
if
(!Loader::includeModule(
'ai'
))
32
{
33
return
false
;
34
}
35
36
$engine
= Engine::getByCategory(
$type
, Context::getFake());
37
38
if
(!
$engine
)
39
{
40
return
false
;
41
}
42
43
return
true
;
44
}
45
46
public
static
function
onTuningLoad
():
Entity
\
EventResult
47
{
48
$result
=
new
Entity\EventResult();
49
50
$items
= [];
51
$groups
= [];
52
53
if
(Engine::getByCategory(self::TEXT_CATEGORY, Context::getFake()))
54
{
55
$items
[self::TUNING_CODE_TEXT_PRODUCT_CARD] = [
56
'group'
=> Tuning\Defaults::GROUP_TEXT,
57
'header'
=> Loc::getMessage(
'CATALOG_AI_SETTINGS_ALLOW_TEXT_PROSUCT_CARD_COPILOT_DESC'
),
58
'title'
=> Loc::getMessage(
'CATALOG_AI_SETTINGS_COPILOT_PRODUCT_CARD_TITLE'
),
59
'type'
=> Tuning\Type::BOOLEAN,
60
'default'
=>
true
,
61
'sort'
=> 700,
62
];
63
}
64
65
$result
->modifyFields([
66
'items'
=>
$items
,
67
'groups'
=>
$groups
,
68
]);
69
70
return
$result
;
71
}
72
}
$type
$type
Определения
options.php:106
Bitrix\Catalog\Integration\AI\Settings
Определения
settings.php:13
Bitrix\Catalog\Integration\AI\Settings\isTextProductCardAvailable
static isTextProductCardAvailable()
Определения
settings.php:17
Bitrix\Catalog\Integration\AI\Settings\onTuningLoad
static onTuningLoad()
Определения
settings.php:46
Bitrix\Catalog\Model\EventResult
Определения
eventresult.php:7
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Localization\Loc
Определения
loc.php:12
$result
$result
Определения
get_property_values.php:14
$groups
$groups
Определения
options.php:30
Bitrix\Catalog\Integration\AI
Определения
settings.php:3
Bitrix\Main\Entity
Определения
ufield.php:9
$items
$items
Определения
template.php:224
$engine
$engine
Определения
options.php:121
bitrix
modules
catalog
lib
integration
ai
settings.php
Создано системой
1.14.0