1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
results.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors;
4
5use Bitrix\Main\ArgumentNullException;
6use Bitrix\Sale\TradingPlatform\Logger;
7use Bitrix\Sale\TradingPlatform\Ebay\Ebay;
8
9class 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 $message = "RequestId: ".$data["ARRAY"]["RequestDetails"]["RequestID"]."\n".
46 "StartTime: ".$data["ARRAY"]["RequestDetails"]["StartTime"]."\n".
47 "EndTime: ".$data["ARRAY"]["RequestDetails"]["EndTime"]."\n\n".
49
52 "EBAY_FEED_RESULTS_ERROR",
53 $data["ARRAY"]["RequestDetails"]["RequestID"],
55 $this->siteId);
56 }
57
58 return true;
59 }
60
61 protected function getProductsString($products)
62 {
63 if(!is_array($products) || empty($products))
64 return "";
65
66 reset($products);
67
68 if(key($products) !== 0)
69 $products = array( 0 => $products);
70
71 $result = "";
72
73 foreach($products as $product)
74 $result .= $this->getProductInfo($product);
75
76 return $result;
77 }
78
79 protected function getProductInfo($product)
80 {
81 if(!is_array($product) || empty($product))
82 return "";
83
84 $result = "";
85
86 if(isset($product["Errors"]["Error"]) || isset($product["Warnings"]["Warning"]))
87 {
88 if(isset($product["ProductID"]))
89 $result .= "\nProductID: ".$product["ProductID"]."\n";
90
91 if(isset($product["Result"]))
92 $result .= "Result: ".$product["Result"]."\n";
93
94 if(isset($product["Action"]))
95 $result .= "Action: ".$product["Action"]."\n";
96 }
97
98 if(isset($product["Errors"]["Error"]))
99 $result .= $this->getErrorsString($product["Errors"]["Error"]);
100
101 if(isset($product["Warnings"]["Warning"]))
102 $result .= $this->getWarningsString($product["Warnings"]["Warning"]);
103
104 return $result;
105 }
106
107 protected function getErrorsString($errors)
108 {
109 if(!is_array($errors) || empty($errors))
110 return "";
111
112 reset($errors);
113
114 if(key($errors) !== 0)
115 $errors = array( 0 => $errors);
116
117 $result = "";
118
119 foreach($errors as $error)
120 $result .= "Error: ".$error["Message"]." (error code: ".$error["Code"].").\n";
121
122 return $result;
123 }
124
125 protected function getWarningsString($warnings)
126 {
127 if(!is_array($warnings) || empty($warnings))
128 return "";
129
130 reset($warnings);
131
132 if(key($warnings) !== 0)
133 $warnings = array( 0 => $warnings);
134
135 $result = "";
136
137 foreach($warnings as $warning)
138 $result .= "Warning: ".$warning["Message"]." (warning code: ".$warning["Code"].").\n";
139
140 return $result;
141 }
142}
static log($level, $type, $itemId, $description, $siteId)
Определения ebay.php:161
const LOG_LEVEL_ERROR
Определения logger.php:15
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
$message
Определения payment.php:8
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$error
Определения subscription_card_product.php:20
$fields
Определения yandex_run.php:501