-
Notifications
You must be signed in to change notification settings - Fork 2
/
addNewDealCategories.php
52 lines (48 loc) · 1.24 KB
/
addNewDealCategories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
class AbstractMigration
{
private function getDealCategories():array
{
return [
[
'CREATED_DATE'=>new \Bitrix\Main\Type\DateTime(),
'NAME'=>'Test',
'SORT'=>50,
],
[
'CREATED_DATE'=>new \Bitrix\Main\Type\DateTime(),
'NAME'=>'Test2',
'SORT'=>60,
],
];
}
public function up()
{
if(!\Bitrix\Main\Loader::includeModule('crm'))
{
return;
}
foreach (self::getDealCategories() as $arCategory)
{
\Bitrix\Crm\Category\Entity\DealCategoryTable::add($arCategory);
}
}
public function down()
{
if(!\Bitrix\Main\Loader::includeModule('crm'))
{
return;
}
foreach (self::getDealCategories() as $arCategory)
{
$res = \Bitrix\Crm\Category\Entity\DealCategoryTable::getList([
'filter'=>['NAME'=>$arCategory['NAME']],
'select'=>['ID'],
])->fetch();
if($res)
{
\Bitrix\Crm\Category\Entity\DealCategoryTable::delete($res['ID']);
}
}
}
}