/** * Starts data exchange. * @param $feedType * @param $siteId * @param string $startPosition * @param bool|false $once * @return string * @throws ArgumentNullException * @throws ArgumentOutOfRangeException */ public static function start($feedType, $siteId, $startPosition = "", $once = false) { if (empty($siteId)) { throw new ArgumentNullException('siteId'); } $siteId = \EscapePHPString($siteId); if (!in_array($feedType, array("ORDER", "PRODUCT", "INVENTORY", "IMAGE"))) { throw new ArgumentOutOfRangeException('feedType'); } $result = ""; $timeLimit = 300; Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_AGENT_FEED_STARTED", $feedType, "Feed: " . $feedType . ", site: " . $siteId . ", start position: " . $startPosition, $siteId); try { if (in_array($feedType, array("ORDER", "PROCESS_RESULT", "RESULTS"))) { $ebayFeed = Manager::createFeed($feedType, $siteId, $timeLimit); $ebayFeed->processData($startPosition); } else { $timer = new Timer($timeLimit); $queue = Manager::createSftpQueue($feedType, $siteId, $timer); $queue->sendData(); } } catch (TimeIsOverException $e) { $result = 'Bitrix\\Sale\\TradingPlatform\\Ebay\\Agent::start("' . $feedType . '","' . $siteId . '","' . $e->getEndPosition() . '",, ' . ($once ? 'true' : 'false') . ');'; } catch (\Exception $e) { Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_FEED_ERROR", $feedType, $e->getMessage(), $siteId); } if (strlen($result) <= 0 && !$once) { $result = 'Bitrix\\Sale\\TradingPlatform\\Ebay\\Agent::start("' . $feedType . '","' . $siteId . '");'; } return $result; }
if (!\Bitrix\Main\Loader::includeModule('sale')) { $arResult["ERROR"] = "Module sale is not installed!"; } $result = false; if (isset($arResult["ERROR"]) <= 0 && $APPLICATION->GetGroupRight("sale") >= "W" && check_bitrix_sessid()) { $action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : ''; $siteId = isset($_REQUEST['siteId']) ? trim($_REQUEST['siteId']) : ''; switch ($action) { case "startFeed": $type = isset($_REQUEST['type']) ? trim($_REQUEST['type']) : ''; $startPosition = isset($_REQUEST['startPos']) ? trim($_REQUEST['startPos']) : ''; try { $ebayFeed = \Bitrix\Sale\TradingPlatform\Ebay\Feed\Manager::createFeed($type, $siteId); $ebayFeed->processData($startPosition); if ($type != "ORDER") { $queue = \Bitrix\Sale\TradingPlatform\Ebay\Feed\Manager::createSftpQueue($type, $siteId); $queue->sendData(); } $arResult["COMPLETED"] = true; } catch (\Bitrix\Sale\TradingPlatform\TimeIsOverException $e) { $arResult["END_POS"] = $e->getEndPosition(); } catch (\Exception $e) { Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_FEED_ERROR", $type, $e->getMessage(), $siteId); $arResult["ERROR"] = $e->getMessage(); } break; case "refreshCategoriesData": $categories = new \Bitrix\Sale\TradingPlatform\Ebay\Api\Categories($siteId); $arResult["COUNT"] = $categories->refreshTableData(); break; case "refreshCategoriesPropsData":