3namespace Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Processors;
5use \Bitrix\Main\Type\DateTime;
6use \Bitrix\Main\SystemException;
7use \Bitrix\Sale\TradingPlatform\Sftp;
8use \Bitrix\Main\ArgumentNullException;
9use \Bitrix\Sale\TradingPlatform\Logger;
10use \Bitrix\Sale\TradingPlatform\Ebay\Ebay;
11use \Bitrix\Sale\TradingPlatform\Ebay\Feed\QueueTable;
12use \Bitrix\Sale\TradingPlatform\Ebay\Feed\ResultsTable;
32 if($this->feedType ==
"ORDER_ACK")
33 $this->feedType =
"order-ack";
35 $this->feedType = mb_strtolower(
$params[
"FEED_TYPE"]);
40 $this->siteId =
$params[
"SITE_ID"];
43 $this->coverTag =
$params[
"COVER_TAG"];
45 if(isset(
$params[
"SCHEMA_FILE_NAME"]))
46 $this->schemeFileName =
$params[
"SCHEMA_FILE_NAME"];
49 $this->timer =
$params[
"TIMER"];
51 $this->fileNameSalt = time();
52 $this->remotePath =
"/store/".$this->feedType;
58 $res = file_put_contents($file,
'<?xml version="1.0" encoding="UTF-8"?>'.
"\n");
61 throw new SystemException(
"Can't flush data feed \"".$this->feedType.
"\" to file ".$file);
63 if($this->coverTag !==
null)
64 file_put_contents($file,
"<".$this->coverTag.
">\n", FILE_APPEND);
71 $feedDataRes = QueueTable::getList(
array(
73 "FEED_TYPE" => $this->feedType
77 $filePrepared =
false;
79 while($feedData = $feedDataRes->fetch())
83 $fileXml = $this->
path.
"/xml/".$this->feedType.
"_".$this->fileNameSalt.
".xml";
90 $res = file_put_contents($fileXml, $feedData[
"DATA"], FILE_APPEND);
93 QueueTable::delete($feedData[
"ID"]);
95 throw new SystemException(
"Can't flush data feed \"".$this->feedType.
"\" to file ".$fileXml);
98 if($this->coverTag !==
null && $filePrepared)
99 file_put_contents($fileXml,
"</".$this->coverTag.
">\n", FILE_APPEND);
112 "FEED_TYPE" => $this->feedType,
126 $tmpFile = $this->
packData($xmlFile);
127 $zipFile = new \Bitrix\Main\IO\File($tmpFile);
128 $zipFile->rename($this->
path.
"/zip/".$this->feedType.
"_".$this->fileNameSalt.
".zip");
131 $checkResultsInterval = 5;
139 $tmpDir = $this->
path.
"/tmp";
140 $archiveName = $tmpDir.
"/".$this->feedType.
"_".$this->fileNameSalt.
".zip";
142 $oArchiver->SetOptions(
array(
143 "REMOVE_PATH" => $this->
path.
"/xml",
144 "ADD_PATH" => $this->feedType
147 if($oArchiver->Pack($xmlFile))
155 $directory = new \Bitrix\Main\IO\Directory($this->
path.
"/zip");
157 if(!$directory->isExists())
160 $filesToSend = $directory->getChildren();
162 if(empty($filesToSend))
165 $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
174 $directoryEntry = $filesToSend[
$i];
180 $remote = $this->remotePath.
"/".$directoryEntry->getName();
184 if($this->timer !==
null && !$this->timer->check(15))
192 $directoryEntry->delete();
193 ResultsTable::add(
array(
194 "FILENAME" => $directoryEntry->getName(),
195 "FEED_TYPE" => $this->feedType,
196 "UPLOAD_TIME" => DateTime::createFromTimestamp(time())
207 $files = $sftp->getFilesList($this->remotePath);
212 if($this->feedType ==
"inventory" || $this->feedType ==
"image")
214 $filesProd = $sftp->getFilesList(
"/store/product");
215 $filesProdInProc = $sftp->getFilesList(
"/store/product/inprocess");
217 if(!empty($filesProd) || !empty($filesProdInProc))
static GetArchive($strArcName, $strType="")
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</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."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']