1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
feed.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\TradingPlatform\Vk\Feed;
4
5use Bitrix\Main\ArgumentException;
6use Bitrix\Sale\TradingPlatform\TimeIsOverException;
7use Bitrix\Sale\TradingPlatform\Timer;
8use Bitrix\Sale\TradingPlatform\Logger;
9use Bitrix\Sale\TradingPlatform\Vk;
10
15class Feed
16{
18 protected $dataConvertor;
22 protected $dataProcessor;
23 protected $feedType;
24 protected $startPosition;
25
27 static $timer = NULL;
28
36 {
37 if (isset($params["TIMER"]) && $params["TIMER"] instanceof Timer)
38 self::$timer = $params["TIMER"];
39
40 if (!isset($params["DATA_SOURCE"]) /*|| (!($params["DATA_SOURCE"] instanceof Data\Sources\DataSource))*/)
41 throw new ArgumentException("DATA_SOURCE must be instanceof DataSource!", "DATA_SOURCE");
42
43 if (!isset($params["DATA_CONVERTER"]) /*|| (!($params["DATA_CONVERTER"] instanceof Data\Converters\DataConverter))*/)
44 throw new ArgumentException("DATA_CONVERTER must be instanceof DataConverter!", "DATA_CONVERTER");
45
46 if (!isset($params["DATA_PROCESSOR"]) || (!($params["DATA_PROCESSOR"] instanceof Data\Processors\DataProcessor)))
47 throw new ArgumentException("DATA_PROCESSOR must be instanceof DataProcessor!", "DATA_PROCESSOR");
48
49 $this->feedType = $params["FEED_TYPE"];
50 $this->sourceDataIterator = $params["DATA_SOURCE"];
51 $this->dataConvertor = $params["DATA_CONVERTER"];
52 $this->dataProcessor = $params["DATA_PROCESSOR"];
53 $this->startPosition = $startPosition;
54 }
55
60 private static function getTimer()
61 {
62 return self::$timer;
63 }
64
72 public function processData($exportId = NULL)
73 {
74// EMPTY data for deleteAll-operations
75 if (!$this->sourceDataIterator)
76 {
77 $this->dataProcessor->process(NULL, self::getTimer());
78 }
79
80 else
81 {
82 $vk = Vk\Vk::getInstance();
83 $executionItemsLimit = $exportId ? $vk->getExecutionItemsLimit($exportId) : Vk\Vk::MAX_EXECUTION_ITEMS;
84
85 $journal = new Vk\Journal($exportId, $this->feedType);
86 $logger = new Vk\Logger($exportId);
87 $logger->addLog('Feed start', 'Feed type ' . $this->feedType);
88
89 $convertedData = array();
90 $nextStepItem = NULL;
91 $nextStepFlag = false;
92
93 foreach ($this->sourceDataIterator as $data)
94 {
95 $logger->addLog('Item to convert', 'ID: ' . $data["ID"] . ' NAME: ' . $data["NAME"]);
96 if ($nextStepFlag)
97 {
98 $nextStepItem = $data["ID"];
99 break;
100 }
101
102 if ($currData = $this->dataConvertor->convert($data))
103 {
104 $convertedData += $currData;
105 }
106
107 if (count($convertedData) >= $executionItemsLimit)
108 {
109 $nextStepFlag = true;
110 }
111 }
112
113// PROCESSING
114 if (count($convertedData) > 0)
115 {
116 $logger->addLog('Items to process', 'Count '.count($convertedData));
117 $this->dataProcessor->process($convertedData, self::getTimer());
118 $logger->addLog('Finish process items', 'Count '.count($convertedData));
119 $journal->addItemsCount(count($convertedData));
120// for running next step
121 if ($nextStepItem)
122 {
123 throw new TimeIsOverException("VK export next step", $nextStepItem);
124 }
125 }
126
127 if (count($convertedData) == 0 && $this->feedType == 'PRODUCTS')
128 {
129 $logger->addError('EMPTY_SECTION_PRODUCTS');
130 }
131
132// all OK - close journal
133 $journal->end();
134
135 $vk->log(
137 "VK_FEED__FEED_FINISH_OK",
138 'FEED_' . $this->feedType,
139 "VKontakte export of " . $this->feedType . " for export profile " . $exportId . " was finished successful. "
140 );
141 }
142 }
143
144}
const LOG_LEVEL_ERROR
Определения logger.php:15
processData($exportId=NULL)
Определения feed.php:72
__construct($params, $startPosition)
Определения feed.php:35
const MAX_EXECUTION_ITEMS
Определения vk.php:33
static getInstance()
Определения vk.php:68
$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
Определения aliases.php:105
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799