示例#1
0
 protected function receiveFiles()
 {
     $result = array();
     $timeToKeepFiles = 24;
     $tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
     CheckDirPath($tmpDir);
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     /*
     $orderFiles = $sftp->getFilesList($this->remotePath);
     
     foreach($orderFiles as $file)
     {
     	if($sftp->downloadFile($this->remotePath."/".$file, $tmpDir.$file))
     	{
     		$result[] = $tmpDir.$file;
     		Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
     	}
     }
     */
     $file = "orderLatest";
     if ($sftp->downloadFile($this->orderLatest, $tmpDir . $file)) {
         $result[] = $tmpDir . $file;
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
     }
     return $result;
 }
示例#2
0
文件: ebay.php 项目: Satariall/izurit
 /**
  * Sends error description to e-mail
  * @param string $type Type of error.
  * @param string $details Error details.
  * @param string $siteId Site id.
  * @return bool
  */
 public function sendErrorMail($type, $details, $siteId)
 {
     if (!isset($this->settings[$siteId]["EMAIL_ERRORS"]) || strlen($this->settings[$siteId]["EMAIL_ERRORS"]) <= 0) {
         return false;
     }
     $loggerTypes = Helper::OnEventLogGetAuditTypes();
     $errorType = isset($loggerTypes[$type]) ? $loggerTypes[$type] : $type;
     $fields = array("EMAIL_TO" => $this->settings[$siteId]["EMAIL_ERRORS"], "ERROR_TYPE" => $errorType, "ERROR_DETAILS" => $details);
     $event = new \CEvent();
     return $event->Send("SALE_EBAY_ERROR", $siteId, $fields, "N");
 }
示例#3
0
 protected function getFileContent($feedData)
 {
     $result = "";
     $timeToKeepFiles = 24;
     $tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
     CheckDirPath($tmpDir);
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     $remotePath = $this->createRemotePath($feedData);
     $files = $sftp->getFilesList($remotePath);
     foreach ($files as $file) {
         if (!strstr($file, $feedData["FILENAME"])) {
             continue;
         }
         if ($sftp->downloadFile($remotePath . "/" . $file, $tmpDir . $file)) {
             $result = file_get_contents($tmpDir . $file);
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_RESULTS_RECEIVED", $file, "File received successfully.", $this->siteId);
         } else {
             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_SOURCE_RESULTS_ERROR", $tmpDir . $file, "Can't receive file content.", $this->siteId);
         }
     }
     return $result;
 }
示例#4
0
 public function executeComponent()
 {
     if (!CModule::IncludeModule('sale')) {
         ShowError("Module sale not installed!");
         return;
     }
     if (!CModule::IncludeModule('catalog')) {
         ShowError("Module catalog not installed!");
         return;
     }
     $this->arResult["BITRIX_CATEGORY_ID"] = isset($this->arParams["BITRIX_CATEGORY_ID"]) ? $this->arParams["BITRIX_CATEGORY_ID"] : 0;
     $this->arResult["IBLOCK_ID"] = isset($this->arParams["IBLOCK_ID"]) ? $this->arParams["IBLOCK_ID"] : 0;
     if (isset($this->arParams["EBAY_CATEGORY_ID"])) {
         $this->arResult["EBAY_CATEGORY_ID"] = $this->arParams["EBAY_CATEGORY_ID"];
     } else {
         $this->arResult["EBAY_CATEGORY_ID"] = $this->getMappedEbayCategoryId($this->arResult["BITRIX_CATEGORY_ID"]);
     }
     $this->arResult["TOP_CATEGORIES_LIST"] = $this->getTopCategories();
     $this->arResult["VARIATIONS_BLOCK_ID"] = 'SALE_EBAY_CAT_' . $this->arResult["EBAY_CATEGORY_ID"] . '_VARIATIONS';
     $siteRes = CIBlock::GetSite($this->arResult["IBLOCK_ID"]);
     //todo: It can be many sites for one iblock.
     if ($site = $siteRes->Fetch()) {
         $this->arResult["SITE_ID"] = $site["LID"];
     } else {
         $this->arResult["SITE_ID"] = "";
     }
     if (strlen($this->arResult["EBAY_CATEGORY_ID"]) > 0) {
         $this->arResult["CATEGORY_AND_PARENTS_INFO"] = $this->getCategoryAndParentsInfo($this->arResult["EBAY_CATEGORY_ID"]);
         if (isset($this->arResult["CATEGORY_AND_PARENTS_INFO"][1]["CATEGORY_ID"])) {
             $this->arResult["TOP_CATEGORY_ID"] = $this->arResult["CATEGORY_AND_PARENTS_INFO"][1]["CATEGORY_ID"];
         }
         $this->arResult["EBAY_CATEGORY_VARIATIONS"] = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayCategoryVariations($this->arResult["EBAY_CATEGORY_ID"], $this->arResult["SITE_ID"]);
         if (isset($this->arParams["VARIATIONS_VALUES"])) {
             $this->arResult["VARIATIONS_VALUES"] = $this->arParams["VARIATIONS_VALUES"];
         } else {
             $this->arResult["VARIATIONS_VALUES"] = $this->getVariationsValues($this->arResult["IBLOCK_ID"], $this->arResult["EBAY_CATEGORY_ID"], $this->arResult["EBAY_CATEGORY_VARIATIONS"]);
         }
     } else {
         $this->arResult["VARIATIONS_VALUES"] = array('' => '');
         $this->arResult["EBAY_CATEGORY_VARIATIONS"] = array();
     }
     $this->arResult["CATEGORY_PROPS"] = \CIBlockSectionPropertyLink::GetArray($this->arParams["IBLOCK_ID"], $this->arParams["BITRIX_CATEGORY_ID"]);
     $rsProps = \CIBlockProperty::GetList(array("SORT" => "ASC", 'ID' => 'ASC'), array("IBLOCK_ID" => $this->arParams["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "ACTIVE" => "Y"));
     while ($arProp = $rsProps->Fetch()) {
         if (isset($this->arResult["CATEGORY_PROPS"][$arProp["ID"]])) {
             $this->arResult["CATEGORY_PROPS"][$arProp["ID"]]["NAME"] = $arProp["NAME"];
         }
     }
     $this->arResult["IBLOCK_IDS"] = array($this->arParams["IBLOCK_ID"] => Loc::getMessage("SALE_EBAY_SEC_CATEGORY_PROP"));
     $arOffers = \CCatalogSKU::GetInfoByProductIBlock($this->arParams["IBLOCK_ID"]);
     if (is_array($arOffers) && !empty($arOffers)) {
         $this->arResult["OFFERS_IBLOCK_ID"] = $arOffers["IBLOCK_ID"];
         $this->arResult["CATEGORY_OFFERS_PROPS"] = \CIBlockSectionPropertyLink::GetArray($arOffers["IBLOCK_ID"], $this->arParams["BITRIX_CATEGORY_ID"]);
         $rsProps = \CIBlockProperty::GetList(array("SORT" => "ASC", 'ID' => 'ASC'), array("IBLOCK_ID" => $arOffers["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "ACTIVE" => "Y"));
         while ($arProp = $rsProps->Fetch()) {
             if (isset($this->arResult["CATEGORY_OFFERS_PROPS"][$arProp["ID"]])) {
                 $this->arResult["CATEGORY_OFFERS_PROPS"][$arProp["ID"]]["NAME"] = $arProp["NAME"];
             }
         }
         $this->arResult["IBLOCK_IDS"][$arOffers["IBLOCK_ID"]] = Loc::getMessage("SALE_EBAY_SEC_OFFERS_PROP");
     }
     $this->IncludeComponentTemplate();
 }
示例#5
0
 protected function createStatusMapHtml()
 {
     $result = "";
     $defaultValues = array("Canceled" => "CANCELED");
     foreach (\Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayOrderStatuses() as $ebayStatus) {
         $value = isset($this->ebaySettings[$this->siteId]["STATUS_MAP"][$ebayStatus]) ? $this->ebaySettings[$this->siteId]["STATUS_MAP"][$ebayStatus] : '';
         if (strlen($value) <= 0 && !empty($defaultValues[$ebayStatus])) {
             $value = $defaultValues[$ebayStatus];
         }
         $result .= '<input type="hidden" name="EBAY_SETTINGS[STATUS_MAP][' . $ebayStatus . ']" value="' . $value . '">';
     }
     $value = isset($this->ebaySettings[$this->siteId]["STATUS_MAP"]["ORDER_READY_MAP"]) ? $this->ebaySettings[$this->siteId]["STATUS_MAP"]["ORDER_READY_MAP"] : 'PAYED';
     $result .= '<input type="hidden" name="EBAY_SETTINGS[ORDER_READY_MAP][ORDER_READY_MAP]" value="' . $value . '">';
     return $result;
 }
示例#6
0
if (isset($arResult["ERROR"]) <= 0 && $USER->IsAdmin() && check_bitrix_sessid()) {
    $action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : '';
    switch ($action) {
        case "get_categories_list":
            $topCategory = isset($_REQUEST['topCategory']) ? intval($_REQUEST['topCategory']) : '';
            $categoriesList = array();
            $categoriesRes = \Bitrix\Sale\TradingPlatform\Ebay\CategoryTable::getList(array('select' => array('CATEGORY_ID', 'NAME', 'LEVEL'), 'order' => array('NAME' => 'ASC'), 'filter' => array('PARENT_ID' => $topCategory)));
            while ($category = $categoriesRes->fetch()) {
                $categoriesList[] = array($category["CATEGORY_ID"], $category["NAME"]);
            }
            $arResult["CATEGORIES_LIST"] = $categoriesList;
            break;
        case "get_variations_list":
            $siteId = isset($_REQUEST['siteId']) ? trim($_REQUEST['siteId']) : '';
            $category = isset($_REQUEST['category']) ? trim($_REQUEST['category']) : '';
            $arResult["VARIATIONS_LIST"] = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayCategoryVariations($category, $siteId);
            break;
        case "get_variation_values":
            $variationId = isset($_REQUEST['variationId']) ? trim($_REQUEST['variationId']) : '';
            $variationRes = Bitrix\Sale\TradingPlatform\Ebay\CategoryVariationTable::getById($variationId);
            if ($variation = $variationRes->fetch()) {
                $arResult["VARIATION_VALUES"] = $variation["VALUE"];
            }
            break;
        case "set_category_property_link":
            if (!\Bitrix\Main\Loader::includeModule('iblock')) {
                $arResult["ERROR"] = "Can't include module Iblock!";
            }
            $bitrixCategoryId = isset($_REQUEST['bitrixCategoryId']) ? trim($_REQUEST['bitrixCategoryId']) : '';
            $properyId = isset($_REQUEST['properyId']) ? trim($_REQUEST['properyId']) : '';
            CIBlockSectionPropertyLink::Add($bitrixCategoryId, $properyId);
示例#7
0
 protected function sendDataSftp()
 {
     $directory = new \Bitrix\Main\IO\Directory($this->path . "/zip");
     if (!$directory->isExists()) {
         throw new SystemException("Directory" . $this->path . "/zip does not exist! " . __METHOD__);
     }
     $filesToSend = $directory->getChildren();
     if (empty($filesToSend)) {
         return false;
     }
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     for ($i = 0; $i < count($filesToSend); $i++) {
         $directoryEntry = $filesToSend[$i];
         $localPath = $directoryEntry->getPath();
         if (!$directoryEntry instanceof \Bitrix\Main\IO\File || GetFileExtension($localPath) != "zip") {
             continue;
         }
         $remote = $this->remotePath . "/" . $directoryEntry->getName();
         while (!$this->checkOuterConditions($sftp)) {
             if ($this->timer !== null && !$this->timer->check(15)) {
                 return false;
             }
             sleep(10);
         }
         if ($sftp->uploadFile($localPath, $remote)) {
             $directoryEntry->delete();
             ResultsTable::add(array("FILENAME" => $directoryEntry->getName(), "FEED_TYPE" => $this->feedType, "UPLOAD_TIME" => DateTime::createFromTimestamp(time())));
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_SFTPQUEUE_SEND", $remote, "File sent successfully.", $this->siteId);
         }
     }
     return true;
 }
示例#8
0
文件: ebay.php 项目: Satariall/izurit
	<tr class="heading"><td colspan="2"><?php 
    echo Loc::getMessage("SALE_EBAY_STATUSES");
    ?>
</td></tr>
	<tr>
		<td width="40%"><b><?php 
    echo Loc::getMessage("SALE_EBAY_STATUSES_EBAY");
    ?>
:</b></td>
		<td width="60%"><b><?php 
    echo Loc::getMessage("SALE_EBAY_STATUSES_BITRIX");
    ?>
:</b></td>
	</tr>
	<?php 
    foreach (\Bitrix\Sale\TradingPlatform\Ebay\Helper::getEbayOrderStatuses() as $ebayStatus) {
        ?>
		<tr>
			<td width="40%">[<?php 
        echo $ebayStatus;
        ?>
]:</td>
			<td width="60%"><?php 
        echo Helper::getSelectHtml("EBAY_SETTINGS[STATUS_MAP][" . $ebayStatus . "]", $bitrixStatuses, $siteSettings["STATUS_MAP"][$ebayStatus]);
        ?>
</td>
		</tr>
	<?php 
    }
    ?>
	<tr>