30 public static function start($feedType, $siteId, $startPosition=
"", $once =
false)
35 $siteId = \EscapePHPString($siteId);
37 if(!in_array($feedType, array(
"ORDER",
"PRODUCT",
"INVENTORY",
"IMAGE",
"PROCESS_RESULT",
"RESULTS",
"ORDER_ACK")))
42 Ebay::log(
Logger::LOG_LEVEL_DEBUG,
"EBAY_AGENT_FEED_STARTED", $feedType,
"Feed: ".$feedType.
", site: ".$siteId.
", start position: ".$startPosition, $siteId);
46 if(in_array($feedType, array(
"ORDER",
"PROCESS_RESULT",
"RESULTS")))
48 $ebayFeed = Manager::createFeed($feedType, $siteId, $timeLimit);
49 $ebayFeed->processData($startPosition);
53 $timer =
new Timer($timeLimit);
54 $queue = Manager::createSftpQueue($feedType, $siteId, $timer);
60 $result =
'Bitrix\Sale\TradingPlatform\Ebay\Agent::start("'.$feedType.
'","'.$siteId.
'","'.$e->
getEndPosition().
'",, '.($once ?
'true' :
'false').
');';
67 if($result ==
'' && !$once)
68 $result =
'Bitrix\Sale\TradingPlatform\Ebay\Agent::start("'.$feedType.
'","'.$siteId.
'");';
82 public static function add($feedType, $siteId, $interval, $once =
false)
90 $siteId = \EscapePHPString($siteId);
92 if($feedType ==
"ORDER")
94 elseif($feedType ==
"PRODUCT" || $feedType ==
"PROCESS_RESULT" || $feedType ==
"RESULTS")
96 elseif($feedType ==
"INVENTORY" || $feedType ==
"IMAGE" || $feedType ==
"ORDER_ACK" )
101 $intervalSeconds = $interval*60;
102 $timeToStart = ConvertTimeStamp(strtotime(date(
'Y-m-d H:i:s', time() + $intervalSeconds)),
'FULL');
104 $result = \CAgent::AddAgent(
105 self::createAgentNameForAdd($feedType, $siteId, $once),
114 Ebay::log(
Logger::LOG_LEVEL_DEBUG,
"EBAY_AGENT_ADDING_RESULT", $feedType,
"Feed: ".$feedType.
", site: ".$siteId.
", interval: ".$interval.
" once: ".($once ?
'true' :
'false').
" agentId: '".$result.
"'", $siteId);
131 public static function update($siteId, array $feedSettings)
133 foreach($feedSettings as $feedType => $feedParams)
135 $interval = intval($feedParams[
"INTERVAL"]);
137 $dbRes = \CAgent::GetList(
140 'NAME' => self::createAgentNameForAdd($feedType, $siteId)
144 if($agent = $dbRes->Fetch())
148 \CAgent::Delete($agent[
"ID"]);
149 $feedSettings[$feedType][
"AGENT_ID"] = 0;
155 array(
'AGENT_INTERVAL' => $interval*60)
158 $feedSettings[$feedType][
"AGENT_ID"] = $agent[
"ID"];
162 $feedSettings[$feedType][
"AGENT_ID"] =
self::add($feedType, $siteId, $feedParams[
"INTERVAL"]);
166 return $feedSettings;