Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
results.php
1
<?php
2
3
namespace
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors
;
4
5
use
Bitrix\Main\ArgumentNullException
;
6
use
Bitrix\Sale\TradingPlatform\Logger
;
7
use
Bitrix\Sale\TradingPlatform\Ebay\Ebay
;
8
9
class
Results
extends
DataProcessor
10
{
11
protected
$siteId
;
12
13
public
function
__construct
($params)
14
{
15
if
(!isset($params[
"SITE_ID"
]) || $params[
"SITE_ID"
] ==
''
)
16
throw
new
ArgumentNullException
(
"SITE_ID"
);
17
18
$this->siteId = $params[
"SITE_ID"
];
19
}
20
21
public
function
process
($data)
22
{
23
if
(!isset($data[
"RESULT_ID"
]))
24
throw
new
ArgumentNullException
(
"data[\"RESULT_ID\"]"
);
25
26
if
(isset($data[
"XML"
]))
27
{
28
$fields[
"RESULTS"
] = $data[
"XML"
];
29
\Bitrix\Sale\TradingPlatform\Ebay\Feed\ResultsTable::update($data[
"RESULT_ID"
], $fields);
30
}
31
32
$message =
""
;
33
34
if
(isset($data[
"ARRAY"
][
"RequestDetails"
][
"Errors"
][
"Error"
]))
35
$message .= $this->
getErrorsString
($data[
"ARRAY"
][
"RequestDetails"
][
"Errors"
][
"Error"
]);
36
37
if
(isset($data[
"ARRAY"
][
"RequestDetails"
][
"Warnings"
][
"Warning"
]))
38
$message .= $this->
getWarningsString
($data[
"ARRAY"
][
"RequestDetails"
][
"Warnings"
][
"Warning"
]);
39
40
if
(isset($data[
"ARRAY"
][
"ProductResult"
]))
41
$message .= $this->
getProductsString
($data[
"ARRAY"
][
"ProductResult"
]);
42
43
if
($message <>
''
)
44
{
45
if
(mb_strtolower(SITE_CHARSET) !=
'utf-8'
)
46
$message = \Bitrix\Main\Text\Encoding::convertEncoding($message,
'UTF-8'
, SITE_CHARSET);
47
48
$message =
"RequestId: "
.$data[
"ARRAY"
][
"RequestDetails"
][
"RequestID"
].
"\n"
.
49
"StartTime: "
.$data[
"ARRAY"
][
"RequestDetails"
][
"StartTime"
].
"\n"
.
50
"EndTime: "
.$data[
"ARRAY"
][
"RequestDetails"
][
"EndTime"
].
"\n\n"
.
51
$message;
52
53
Ebay::log
(
54
Logger::LOG_LEVEL_ERROR
,
55
"EBAY_FEED_RESULTS_ERROR"
,
56
$data[
"ARRAY"
][
"RequestDetails"
][
"RequestID"
],
57
$message,
58
$this->siteId);
59
}
60
61
return
true
;
62
}
63
64
protected
function
getProductsString
($products)
65
{
66
if
(!is_array($products) || empty($products))
67
return
""
;
68
69
reset($products);
70
71
if
(key($products) !== 0)
72
$products = array( 0 => $products);
73
74
$result =
""
;
75
76
foreach
($products as $product)
77
$result .= $this->
getProductInfo
($product);
78
79
return
$result;
80
}
81
82
protected
function
getProductInfo
($product)
83
{
84
if
(!is_array($product) || empty($product))
85
return
""
;
86
87
$result =
""
;
88
89
if
(isset($product[
"Errors"
][
"Error"
]) || isset($product[
"Warnings"
][
"Warning"
]))
90
{
91
if
(isset($product[
"ProductID"
]))
92
$result .=
"\nProductID: "
.$product[
"ProductID"
].
"\n"
;
93
94
if
(isset($product[
"Result"
]))
95
$result .=
"Result: "
.$product[
"Result"
].
"\n"
;
96
97
if
(isset($product[
"Action"
]))
98
$result .=
"Action: "
.$product[
"Action"
].
"\n"
;
99
}
100
101
if
(isset($product[
"Errors"
][
"Error"
]))
102
$result .= $this->
getErrorsString
($product[
"Errors"
][
"Error"
]);
103
104
if
(isset($product[
"Warnings"
][
"Warning"
]))
105
$result .= $this->
getWarningsString
($product[
"Warnings"
][
"Warning"
]);
106
107
return
$result;
108
}
109
110
protected
function
getErrorsString
($errors)
111
{
112
if
(!is_array($errors) || empty($errors))
113
return
""
;
114
115
reset($errors);
116
117
if
(key($errors) !== 0)
118
$errors = array( 0 => $errors);
119
120
$result =
""
;
121
122
foreach
($errors as $error)
123
$result .=
"Error: "
.$error[
"Message"
].
" (error code: "
.$error[
"Code"
].
").\n"
;
124
125
return
$result;
126
}
127
128
protected
function
getWarningsString
($warnings)
129
{
130
if
(!is_array($warnings) || empty($warnings))
131
return
""
;
132
133
reset($warnings);
134
135
if
(key($warnings) !== 0)
136
$warnings = array( 0 => $warnings);
137
138
$result =
""
;
139
140
foreach
($warnings as $warning)
141
$result .=
"Warning: "
.$warning[
"Message"
].
" (warning code: "
.$warning[
"Code"
].
").\n"
;
142
143
return
$result;
144
}
145
}
Bitrix\Main\ArgumentNullException
Definition
exception.php:54
Bitrix\Main\Diag\Logger
Definition
logger.php:19
Bitrix\Sale\TradingPlatform\Ebay\Ebay
Definition
ebay.php:12
Bitrix\Sale\TradingPlatform\Ebay\Ebay\log
static log($level, $type, $itemId, $description, $siteId)
Definition
ebay.php:147
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\DataProcessor
Definition
dataprocessor.php:6
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results
Definition
results.php:10
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\getErrorsString
getErrorsString($errors)
Definition
results.php:110
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\getProductInfo
getProductInfo($product)
Definition
results.php:82
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\process
process($data)
Definition
results.php:21
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\__construct
__construct($params)
Definition
results.php:13
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\getProductsString
getProductsString($products)
Definition
results.php:64
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\getWarningsString
getWarningsString($warnings)
Definition
results.php:128
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors\Results\$siteId
$siteId
Definition
results.php:11
Bitrix\Sale\TradingPlatform\Logger\LOG_LEVEL_ERROR
const LOG_LEVEL_ERROR
Definition
logger.php:15
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors
Definition
dataprocessor.php:3
modules
sale
lib
tradingplatform
ebay
feed
data
processors
results.php
Создано системой
1.10.0