Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
manager.php
1<?php
2
4
5use \Bitrix\Main\SystemException;
6use \Bitrix\Sale\TradingPlatform\Timer;
7use \Bitrix\Sale\TradingPlatform\Logger;
8use \Bitrix\Sale\TradingPlatform\Ebay\Ebay;
9
11{
12 public static function createSftpQueue($feedType, $siteId, Timer $timer = null)
13 {
14 $params = array(
15 "SITE_ID" => $siteId,
16 "TIMER" => $timer
17 );
18
19 switch($feedType)
20 {
21 case 'PRODUCT':
22 $params["FEED_TYPE"] = "product";
23 $params["COVER_TAG"] = "ListingArray";
24 $params["SCHEMA_FILE_NAME"] = "Product.xsd";
25 break;
26
27 case 'INVENTORY':
28 $params["FEED_TYPE"] = "inventory";
29 $params["COVER_TAG"] = "InventoryArray";
30 $params["SCHEMA_FILE_NAME"] = "Inventory.xsd";
31 break;
32
33 case 'ORDER_ACK':
34 $params["FEED_TYPE"] = "order-ack";
35 $params["COVER_TAG"] = "OrderAckArray";
36 $params["SCHEMA_FILE_NAME"] = "OrderAck.xsd";
37 break;
38
39 case 'SHIPMENT':
40 $params["FEED_TYPE"] = "shipment";
41 $params["COVER_TAG"] = "ShipmentArray";
42 $params["SCHEMA_FILE_NAME"] = "Shipment.xsd";
43 break;
44
45 case 'IMAGE':
46 $params["FEED_TYPE"] = "image";
47 $params["COVER_TAG"] = "Images";
48 $params["SCHEMA_FILE_NAME"] = "Image.xsd";
49 break;
50
51 default:
52 throw new SystemException("Unknown type of feed \"".$feedType."\". ".__METHOD__);
53 break;
54 }
55 return new Data\Processors\SftpQueue($params);
56 }
57
65 public static function createFeed($feedType, $siteId, $timeLimit = 0)
66 {
67 $timer = new Timer($timeLimit);
68 $feepParams = array(
69 "TIMER" => new $timer,
70 "SITE_ID" => $siteId
71 );
72
73 switch($feedType)
74 {
75 case 'PRODUCT':
76 $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
77 $feepParams["DATA_CONVERTER"] = new Data\Converters\Product(array("SITE_ID" => $siteId));
78 $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
79 break;
80
81 case 'INVENTORY':
82 $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
83 $feepParams["DATA_CONVERTER"] = new Data\Converters\Inventory(array("SITE_ID" => $siteId));
84 $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
85 break;
86
87 case 'ORDER':
88 $feepParams["DATA_SOURCE"] = new Data\Sources\Order(array(
89 "FEED_TYPE" => "order",
90 "SCHEMA_FILE_NAME" => "Order.xsd",
91 "SITE_ID" => $siteId
92 ));
93 $feepParams["DATA_CONVERTER"] = new Data\Converters\Order;
94 $feepParams["DATA_PROCESSOR"] = new Data\Processors\Order(array("SITE_ID" => $siteId));
95 break;
96
97 case 'ORDER_ACK':
98 $feepParams["DATA_SOURCE"] = new Data\Sources\SimpleArray;
99 $feepParams["DATA_CONVERTER"] = new Data\Converters\OrderAck;
100 $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
101 break;
102
103 case 'SHIPMENT':
104 $feepParams["DATA_SOURCE"] = new Data\Sources\SimpleArray;
105 $feepParams["DATA_CONVERTER"] = new Data\Converters\Shipment;
106 $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
107 break;
108
109 case 'IMAGE':
110 $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
111 $feepParams["DATA_CONVERTER"] = new Data\Converters\Image(array("SITE_ID" => $siteId));
112 $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
113 break;
114
115 case 'PROCESS_RESULT':
116 $feepParams["DATA_SOURCE"] = new Data\Sources\Results(array(
117 "SITE_ID" => $siteId,
118 "REMOTE_PATH_TMPL" => "/store/##FEED_TYPE##/log/##UPLOAD_DATE##",
119 "FILTER" => array(
120 "PROCESSING_REQUEST_ID" => ""
121 )
122 ));
123 $feepParams["DATA_CONVERTER"] = new Data\Converters\ProcessResult;
124 $feepParams["DATA_PROCESSOR"] = new Data\Processors\ProcessResult;
125 break;
126
127 case 'RESULTS':
128 $feepParams["DATA_SOURCE"] = new Data\Sources\Results(array(
129 "SITE_ID" => $siteId,
130 "REMOTE_PATH_TMPL" => "/store/##FEED_TYPE##/output/##UPLOAD_DATE##",
131 "FILTER" => array(
132 "RESULTS" => ""
133 )
134 ));
135 $feepParams["DATA_CONVERTER"] = new Data\Converters\Results;
136 $feepParams["DATA_PROCESSOR"] = new Data\Processors\Results(array("SITE_ID" => $siteId));;
137 break;
138
139 default:
140 throw new SystemException("Unknown type of feed \"".$feedType."\". ".__METHOD__);
141 break;
142 }
143
144 $feed = new Feed($feepParams);
145 Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_FEED_CREATED", $feedType, "Feed: ".$feedType.", site: ".$siteId, $siteId);
146 return $feed;
147 }
148}
static log($level, $type, $itemId, $description, $siteId)
Definition ebay.php:147
static createSftpQueue($feedType, $siteId, Timer $timer=null)
Definition manager.php:12
static createFeed($feedType, $siteId, $timeLimit=0)
Definition manager.php:65