Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
category.php
1
<?php
2
namespace
Bitrix\Sale\TradingPlatform\Ebay
;
3
4
use
Bitrix\Main\Entity
;
5
use \Bitrix\Main\Type\DateTime;
6
use
Bitrix\Main\Localization\Loc
;
7
8
Loc::loadMessages
(__FILE__);
9
44
class
CategoryTable
extends
Entity\DataManager
45
{
46
public
static
function
getFilePath
()
47
{
48
return
__FILE__;
49
}
50
51
public
static
function
getTableName
()
52
{
53
return
'b_sale_tp_ebay_cat'
;
54
}
55
56
public
static
function
getMap
()
57
{
58
return
array(
59
'ID'
=> array(
60
'data_type'
=>
'integer'
,
61
'primary'
=>
true
,
62
'autocomplete'
=>
true
,
63
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_ID_FIELD'
),
64
),
65
'NAME'
=> array(
66
'data_type'
=>
'string'
,
67
'validation'
=> array(__CLASS__,
'validateName'
),
68
'required'
=>
true
,
69
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_NAME_FIELD'
),
70
),
71
'CATEGORY_ID'
=> array(
72
'data_type'
=>
'integer'
,
73
'required'
=>
true
,
74
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_CATEGORY_ID_FIELD'
),
75
),
76
'PARENT_ID'
=> array(
77
'data_type'
=>
'integer'
,
78
'required'
=>
true
,
79
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_PARENT_ID_FIELD'
),
80
),
81
'LEVEL'
=> array(
82
'data_type'
=>
'integer'
,
83
'required'
=>
true
,
84
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_LEVEL_FIELD'
),
85
),
86
'LAST_UPDATE'
=> array(
87
'data_type'
=>
'datetime'
,
88
'required'
=>
false
,
89
'default_value'
=>
DateTime::createFromTimestamp
(time()),
90
'title'
=>
Loc::getMessage
(
'TRADING_PLATFORM_EBAY_GENERAL_METADATA_ENTITY_LAST_UPDATE_FIELD'
),
91
),
92
);
93
}
94
99
public
static
function
getCategoryParents
($ebayCategoryId)
100
{
101
$result = array();
102
103
do
104
{
105
$categoryRes = self::getList(array(
106
'select'
=>array(
'CATEGORY_ID'
,
'NAME'
,
'PARENT_ID'
,
'LEVEL'
),
107
'filter'
=> array(
108
'CATEGORY_ID'
=> $ebayCategoryId
109
),
110
));
111
112
if
($category = $categoryRes->fetch())
113
{
114
$result[$category[
"LEVEL"
]] = $category;
115
$ebayCategoryId = $category[
"PARENT_ID"
];
116
}
117
else
118
{
119
break
;
120
}
121
}
122
while
($category[
"LEVEL"
] > 1 || $category[
"PARENT_ID"
] != $category[
"CATEGORY_ID"
]);
123
124
return
array_reverse($result,
true
);
125
}
126
133
public
static
function
update
($primary, array $data)
134
{
135
$data[
"LAST_UPDATE"
] =
DateTime::createFromTimestamp
(time());
136
return
parent::update($primary, $data);
137
}
138
139
public
static
function
validateName
()
140
{
141
return
array(
142
new
Entity
\Validator\Length(
null
, 255),
143
);
144
}
145
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\Type\DateTime\createFromTimestamp
static createFromTimestamp($timestamp)
Definition
datetime.php:246
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable
Definition
category.php:45
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\getMap
static getMap()
Definition
category.php:56
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\getFilePath
static getFilePath()
Definition
category.php:46
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\getCategoryParents
static getCategoryParents($ebayCategoryId)
Definition
category.php:99
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\validateName
static validateName()
Definition
category.php:139
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\update
static update($primary, array $data)
Definition
category.php:133
Bitrix\Sale\TradingPlatform\Ebay\CategoryTable\getTableName
static getTableName()
Definition
category.php:51
Bitrix\Sale\TradingPlatform\Ebay
Definition
agent.php:3
modules
sale
lib
tradingplatform
ebay
category.php
Создано системой
1.10.0