예제 #1
0
파일: order.php 프로젝트: Satariall/izurit
 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
 public function process($data)
 {
     if (!isset($data["RESULT_ID"])) {
         throw new ArgumentNullException("data[\"RESULT_ID\"]");
     }
     if (isset($data["XML"])) {
         $fields["RESULTS"] = $data["XML"];
         \Bitrix\Sale\TradingPlatform\Ebay\Feed\ResultsTable::update($data["RESULT_ID"], $fields);
     }
     $message = "";
     if (isset($data["ARRAY"]["RequestDetails"]["Errors"]["Error"])) {
         $message .= $this->getErrorsString($data["ARRAY"]["RequestDetails"]["Errors"]["Error"]);
     }
     if (isset($data["ARRAY"]["RequestDetails"]["Warnings"]["Warning"])) {
         $message .= $this->getWarningsString($data["ARRAY"]["RequestDetails"]["Warnings"]["Warning"]);
     }
     if (isset($data["ARRAY"]["ProductResult"])) {
         $message .= $this->getProductsString($data["ARRAY"]["ProductResult"]);
     }
     if (strlen($message) > 0) {
         $message = "RequestId: " . $data["ARRAY"]["RequestDetails"]["RequestID"] . "\n" . "StartTime: " . $data["ARRAY"]["RequestDetails"]["StartTime"] . "\n" . "EndTime: " . $data["ARRAY"]["RequestDetails"]["EndTime"] . "\n\n" . $message;
         Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_FEED_RESULTS_ERROR", $data["ARRAY"]["RequestDetails"]["RequestID"], $message, $this->siteId);
     }
     return true;
 }
예제 #3
0
파일: ebay.php 프로젝트: Satariall/izurit
 /**
  * Installs all necessary stuff for Ebay.
  * @return bool
  */
 public function install()
 {
     RegisterModuleDependences('main', 'OnEventLogGetAuditTypes', 'sale', '\\Bitrix\\Sale\\TradingPlatform\\Ebay\\Helper', 'OnEventLogGetAuditTypes');
     $tptAddRes = \Bitrix\Sale\TradingPlatformTable::add(array("CODE" => $this->getCode(), "ACTIVE" => "N", "NAME" => Loc::getMessage("SALE_EBAY_NAME"), "DESCRIPTION" => Loc::getMessage("SALE_EBAY_DESCRIPTION"), "CATALOG_SECTION_TAB_CLASS_NAME" => '\\Bitrix\\Sale\\TradingPlatform\\Ebay\\CatalogSectionTabHandler', "CLASS" => '\\Bitrix\\Sale\\TradingPlatform\\Ebay\\Ebay'));
     $ebay = Ebay::getInstance();
     $catMapEntRes = \Bitrix\Sale\TradingPlatform\MapEntityTable::add(array("TRADING_PLATFORM_ID" => $ebay->getId(), "CODE" => "CATEGORY"));
     $eventRes = Helper::installEvents();
     $fsRes = Helper::createFeedFileStructure();
     return $tptAddRes->isSuccess() && $catMapEntRes->isSuccess() && $eventRes && $fsRes;
 }
예제 #4
0
 protected function getMappedCategories()
 {
     $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     $settings = $ebay->getSettings();
     $iblocksIds = array();
     $result = array();
     foreach ($settings[$this->siteId]["IBLOCK_ID"] as $iblockId) {
         $iblocksIds[] = \Bitrix\Sale\TradingPlatform\Ebay\MapHelper::getCategoryEntityId($iblockId);
     }
     $catMapRes = \Bitrix\Sale\TradingPlatform\MapTable::getList(array("filter" => array("ENTITY_ID" => $iblocksIds)));
     while ($arMapRes = $catMapRes->fetch()) {
         $result = $arMapRes["VALUE_EXTERNAL"];
     }
     return $result;
 }
예제 #5
0
 public function __construct($siteId)
 {
     if (!isset($siteId)) {
         throw new ArgumentNullException("siteId");
     }
     $this->siteId = $siteId;
     $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     $settings = $ebay->getSettings();
     if (empty($settings[$siteId]["API"]["SITE_ID"])) {
         throw new SystemException("EBAY API SITE_ID is not defined!");
     }
     if (empty($settings[$siteId]["API"]["SITE_ID"])) {
         throw new ArgumentNullException("EBAY AUTH_TOKEN is not defined!");
     }
     $this->ebaySiteId = $settings[$siteId]["API"]["SITE_ID"];
     $this->authToken = $settings[$siteId]["API"]["AUTH_TOKEN"];
     $this->apiCaller = new Caller(array("EBAY_SITE_ID" => $settings[$siteId]["API"]["SITE_ID"], "URL" => $ebay->getApiUrl()));
 }
예제 #6
0
 /**
  * @param string $mapEntityCode Map entity code
  * @return int Map entity id.
  * @throws \Bitrix\Main\SystemException
  */
 protected static function getMapEntityId($mapEntityCode)
 {
     $result = 0;
     $ebay = Ebay::getInstance();
     $fields = array("TRADING_PLATFORM_ID" => $ebay->getId(), "CODE" => $mapEntityCode);
     $catMapVarEntRes = MapEntityTable::getList(array("filter" => $fields));
     if ($arCatVarMapEnt = $catMapVarEntRes->fetch()) {
         $result = $arCatVarMapEnt["ID"];
     } else {
         $addRes = MapEntityTable::add($fields);
         if ($addRes->isSuccess()) {
             $result = $addRes->getId();
         }
     }
     if ($result <= 0) {
         throw new SystemException("Can' t get map entity id for code: " . $mapEntityCode . ".");
     }
     return $result;
 }
예제 #7
0
파일: image.php 프로젝트: Satariall/izurit
 public function convert($data)
 {
     $result = "";
     $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     $ebaySettings = $ebay->getSettings();
     $this->morePhotoProp = isset($ebaySettings[$this->siteId]["MORE_PHOTO_PROP"][$data["IBLOCK_ID"]]) ? $ebaySettings[$this->siteId]["MORE_PHOTO_PROP"][$data["IBLOCK_ID"]] : null;
     if (!$this->morePhotoProp) {
         return "";
     }
     $this->domainName = isset($ebaySettings[$this->siteId]["DOMAIN_NAME"]) ? $ebaySettings[$this->siteId]["DOMAIN_NAME"] : null;
     if (!empty($data["OFFERS"]) && is_array($data["OFFERS"])) {
         foreach ($data["OFFERS"] as $offer) {
             $result .= $this->getItemData($offer, $data["IBLOCK_ID"] . "_" . $data["ID"] . "_" . $offer["ID"]);
         }
     } else {
         $result = $this->getItemData($data, $data["IBLOCK_ID"] . "_" . $data["ID"]);
     }
     return $result;
 }
예제 #8
0
 public function __construct($params)
 {
     $this->ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     if (!$this->ebay->isActive()) {
         throw new SystemException("Ebay is not active!" . __METHOD__);
     }
     if (!isset($params["SITE_ID"]) || strlen($params["SITE_ID"]) <= 0) {
         throw new ArgumentNullException("SITE_ID");
     }
     $this->siteId = $params["SITE_ID"];
     if (!\Bitrix\Main\Loader::includeModule('catalog')) {
         throw new SystemException("Can't include module \"Catalog\"! " . __METHOD__);
     }
     $iBlockIds = $this->getIblockIds();
     if (empty($iBlockIds)) {
         throw new SystemException("Can't find iblocks ids! " . __METHOD__);
     }
     foreach ($iBlockIds as $iblockId) {
         $this->productFeeds[] = \Bitrix\Catalog\ExportOfferCreator::getOfferObject(array("IBLOCK_ID" => $iblockId, "PRODUCT_GROUPS" => $this->getMappedGroups($iblockId), "XML_DATA" => $this->getXmlData(), "SETUP_SERVER_NAME" => $this->getDomainName()));
     }
 }
예제 #9
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;
 }
예제 #10
0
 protected function getPolicyForCategory($iblockId, $ebayCategory)
 {
     static $result = array();
     if (!isset($result[$ebayCategory])) {
         $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
         $settings = $ebay->getSettings();
         $siteSettings = $settings[$this->siteId];
         $policyReturnId = "";
         $policyPaymentId = "";
         $policyShippingId = "";
         $result[$ebayCategory] = array();
         foreach ($this->getEbayCategoriesParams($iblockId) as $categoryParams) {
             if ($categoryParams["VALUE_EXTERNAL"] != $ebayCategory) {
                 continue;
             }
             if (!empty($categoryParams["PARAMS"]["POLICY"])) {
                 if (!empty($categoryParams["PARAMS"]["POLICY"]["RETURN"])) {
                     $policyReturnId = $categoryParams["PARAMS"]["POLICY"]["RETURN"];
                 }
                 if (!empty($categoryParams["PARAMS"]["POLICY"]["SHIPPING"])) {
                     $policyShippingId = $categoryParams["PARAMS"]["POLICY"]["SHIPPING"];
                 }
                 if (!empty($categoryParams["PARAMS"]["POLICY"]["PAYMENT"])) {
                     $policyPaymentId = $categoryParams["PARAMS"]["POLICY"]["PAYMENT"];
                 }
             }
             if (strlen($policyReturnId) <= 0 && !empty($siteSettings["POLICY"]["RETURN"]["DEFAULT"])) {
                 $policyReturnId = $siteSettings["POLICY"]["RETURN"]["DEFAULT"];
             }
             if (strlen($policyShippingId) <= 0 && !empty($siteSettings["POLICY"]["SHIPPING"]["DEFAULT"])) {
                 $policyShippingId = $siteSettings["POLICY"]["SHIPPING"]["DEFAULT"];
             }
             if (strlen($policyPaymentId) <= 0 && !empty($siteSettings["POLICY"]["PAYMENT"]["DEFAULT"])) {
                 $policyPaymentId = $siteSettings["POLICY"]["PAYMENT"]["DEFAULT"];
             }
             if ($policyReturnId != "" && !empty($siteSettings["POLICY"]["RETURN"]["LIST"][$policyReturnId])) {
                 $result[$ebayCategory]["RETURN"] = $siteSettings["POLICY"]["RETURN"]["LIST"][$policyReturnId];
             }
             if ($policyShippingId != "" && !empty($siteSettings["POLICY"]["SHIPPING"]["LIST"][$policyShippingId])) {
                 $result[$ebayCategory]["SHIPPING"] = $siteSettings["POLICY"]["SHIPPING"]["LIST"][$policyShippingId];
             }
             if ($policyPaymentId != "" && !empty($siteSettings["POLICY"]["PAYMENT"]["LIST"][$policyPaymentId])) {
                 $result[$ebayCategory]["PAYMENT"] = $siteSettings["POLICY"]["PAYMENT"]["LIST"][$policyPaymentId];
             }
             break;
         }
     }
     return $result[$ebayCategory];
 }
예제 #11
0
 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":
         $categoriesProps = new \Bitrix\Sale\TradingPlatform\Ebay\Api\Categories($siteId);
         $arResult["COUNT"] = $categoriesProps->refreshVariationsTableData();
         break;
     default:
         $arResult["ERROR"] = "Wrong action";
         break;
 }
예제 #12
0
 public function processOrder($orderEbay)
 {
     Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_DATA_PROCESSOR_ORDER_PROCESSING", $orderEbay["ExtendedOrderID"], print_r($orderEbay, true), $this->siteId);
     /*
      * only in this case order is completely ready for shipping
      */
     if ($orderEbay["OrderStatus"] != "Completed" || !isset($orderEbay["CheckoutStatus"]["eBayPaymentStatus"]) || $orderEbay["CheckoutStatus"]["eBayPaymentStatus"] != "NoPaymentFailure") {
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_ORDER_SKIPPED", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_SKIPPED", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"])), $this->siteId);
         return array();
     }
     $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     $settings = $ebay->getSettings();
     if (!isset($settings[$this->siteId]["ORDER_PROPS"]) || !is_array($settings[$this->siteId]["ORDER_PROPS"])) {
         throw new SystemException("Can't get order props map");
     }
     $propsMap = $settings[$this->siteId]["ORDER_PROPS"];
     /*
     if(strtolower(SITE_CHARSET) != 'utf-8')
     	$orderEbay = \Bitrix\Main\Text\Encoding::convertEncodingArray($orderEbay, 'UTF-8', SITE_CHARSET);
     */
     $dbRes = OrderTable::getList(array("filter" => array("TRADING_PLATFORM_ID" => $ebay->getId(), "EXTERNAL_ORDER_ID" => $orderEbay["ExtendedOrderID"])));
     if ($orderCorrespondence = $dbRes->fetch()) {
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_ORDER_ALREADY_EXIST", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_SKIPPED_EXIST", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"])), $this->siteId);
         return array();
     }
     /** @var \Bitrix\Sale\Order $order */
     $order = \Bitrix\Sale\Order::create($this->siteId);
     $order->setPersonTypeId($settings[$this->siteId]["PERSON_TYPE"]);
     $propsCollection = $order->getPropertyCollection();
     /** @var \Bitrix\Sale\PropertyValueCollection $propCollection */
     if (intval($propsMap["FIO"]) > 0) {
         $prop = $propsCollection->getItemByOrderPropertyId($propsMap["FIO"]);
         $prop->setValue($orderEbay["ShippingAddress"]["Name"]);
     }
     if (intval($propsMap["CITY"]) > 0) {
         $prop = $propsCollection->getItemByOrderPropertyId($propsMap["CITY"]);
         $prop->setValue($orderEbay["ShippingAddress"]["CityName"]);
     }
     if (intval($propsMap["PHONE"]) > 0) {
         $prop = $propsCollection->getItemByOrderPropertyId($propsMap["PHONE"]);
         $prop->setValue($orderEbay["ShippingAddress"]["Phone"]);
     }
     if (intval($propsMap["ZIP"]) > 0) {
         $prop = $propsCollection->getItemByOrderPropertyId($propsMap["ZIP"]);
         $prop->setValue($orderEbay["ShippingAddress"]["PostalCode"]);
     }
     if (intval($propsMap["ADDRESS"]) > 0) {
         $prop = $propsCollection->getItemByOrderPropertyId($propsMap["ADDRESS"]);
         $prop->setValue($orderEbay["ShippingAddress"]["CountryName"] . " " . $orderEbay["ShippingAddress"]["CityName"] . " " . $orderEbay["ShippingAddress"]["Street1"] . " " . (!empty($orderEbay["ShippingAddress"]["Street2"]) ? $orderEbay["ShippingAddress"]["Street2"] . " " : ""));
     }
     $basket = null;
     $bitrixOrderId = 0;
     $userId = 0;
     $orderLineItemsIds = array();
     $transactionsArray = $this->normalizeTransactionsArray($orderEbay["TransactionArray"]);
     foreach ($transactionsArray as $transaction) {
         //if we have more than one transaction let's create user from the first
         if ($userId <= 0) {
             if (intval($propsMap["EMAIL"]) > 0 && !empty($transaction["Buyer"]["Email"])) {
                 $prop = $propsCollection->getItemByOrderPropertyId($propsMap["EMAIL"]);
                 $prop->setValue($transaction["Buyer"]["Email"]);
                 $userId = $this->createUser($transaction["Buyer"]["Email"], array("NAME" => $transaction["Buyer"]["UserFirstName"], "LAST_NAME" => $transaction["Buyer"]["UserLastName"]));
             }
             if ($userId <= 0) {
                 $userId = \CSaleUser::GetAnonymousUserID();
             }
         }
         if (intval($userId > 0)) {
             $order->setFieldNoDemand("USER_ID", $userId);
         }
         $fUserId = null;
         if ($order->getUserId() > 0) {
             $fUserId = Fuser::getIdByUserId($order->getUserId());
         }
         /** @var \Bitrix\Sale\Basket $basket */
         if (!$basket) {
             $basket = \Bitrix\Sale\Basket::create($this->siteId);
             $basket->setFUserId($fUserId);
         }
         $items = array();
         $isVariation = false;
         if (!empty($transaction["Item"])) {
             $items = Xml2Array::normalize($transaction["Item"]);
         } elseif (!empty($transaction["Variation"])) {
             $items = Xml2Array::normalize($transaction["Variation"]);
             $isVariation = true;
         }
         if (empty($items)) {
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_ORDER_PROCESSING_TRANSACTION_ITEM_NOT_FOUND", $transaction["OrderLineItemID"], print_r($transaction, true), $this->siteId);
             continue;
         }
         foreach ($items as $transactionItem) {
             $ebaySku = $isVariation ? $this->getSkuVariation($transactionItem["SKU"]) : $this->getSku($transactionItem["SKU"]);
             if (strlen($ebaySku) <= 0) {
                 Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_ORDER_PROCESSING_TRANSACTION_ITEM_SKU_NOT_FOUND", $transaction["OrderLineItemID"], print_r($transaction, true), $this->siteId);
                 continue;
             }
             $item = $basket->createItem('catalog', $ebaySku);
             $item->setField("PRODUCT_PROVIDER_CLASS", "CCatalogProductProvider");
             $itemData = array("CUSTOM_PRICE" => "Y", "PRICE" => floatval($transaction["TransactionPrice"]), "QUANTITY" => floatval($transaction["QuantityPurchased"]), "NAME" => !empty($transactionItem["VariationTitle"]) ? $transactionItem["VariationTitle"] : $transactionItem["Title"], "CURRENCY" => SiteCurrencyTable::getSiteCurrency($this->siteId));
             $data = Provider::getProductData($basket);
             if (!empty($data[$item->getBasketCode()])) {
                 $itemData = array_merge($data[$item->getBasketCode()], $itemData);
             } else {
                 $item->delete();
                 $item = $basket->createItem('', $ebaySku);
             }
             $res = $item->setFields($itemData);
             if ($res->isSuccess()) {
                 $orderLineItemsIds[] = $transaction["OrderLineItemID"];
             } else {
                 foreach ($res->getErrors() as $error) {
                     Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_TRANSACTION_ITEM_CREATE_ERROR", $transaction["OrderLineItemID"], $error->getMessage(), $this->siteId);
                 }
             }
         }
     }
     $res = $order->setBasket($basket);
     if (!$res->isSuccess()) {
         foreach ($res->getErrors() as $error) {
             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_CREATE_ERROR_SET_BASKET", $orderEbay["ExtendedOrderID"], $error->getMessage(), $this->siteId);
         }
     }
     //payments
     if (intval($settings[$this->siteId]["MAPS"]["PAYMENT"]["PayPal"]) > 0) {
         $payments = $order->getPaymentCollection();
         /** @var \Bitrix\Sale\Payment $payment */
         if ($payments->count() > 0) {
             foreach ($payments as $payment) {
                 if ($payment->isPaid()) {
                     $payment->setPaid("N");
                 }
                 $payment->delete();
             }
         }
         $payment = $payments->createItem();
         $payment->setField('PAY_SYSTEM_ID', $settings[$this->siteId]["MAPS"]["PAYMENT"]["PayPal"]);
         $payment->setField('PAY_SYSTEM_NAME', "PayPal via Ebay");
         if ($orderEbay["CheckoutStatus"]["eBayPaymentStatus"] == "NoPaymentFailure" && $orderEbay["MonetaryDetails"]["Payments"]["Payment"]["PaymentStatus"] && $orderEbay["MonetaryDetails"]["Payments"]["Payment"]["PaymentAmount"] == $orderEbay["Total"]) {
             $payment->setField("SUM", $orderEbay["AmountPaid"]);
             $payment->setPaid("Y");
         }
     }
     //shipment
     if (intval($settings[$this->siteId]["MAPS"]["SHIPMENT"][$orderEbay["ShippingServiceSelected"]["ShippingService"]]) > 0) {
         $shipments = $order->getShipmentCollection();
         /** @var \Bitrix\Sale\Shipment $shipment */
         if ($shipments->count() > 0) {
             foreach ($shipments as $shipment) {
                 if (!$shipment->isSystem()) {
                     $shipment->delete();
                 }
             }
         }
         $shipment = $shipments->createItem();
         $shipment->setField('DELIVERY_ID', $settings[$this->siteId]["MAPS"]["SHIPMENT"][$orderEbay["ShippingServiceSelected"]["ShippingService"]]);
         $shipment->setField('CUSTOM_PRICE_DELIVERY', "Y");
         $shipment->setField('BASE_PRICE_DELIVERY', $orderEbay["ShippingServiceSelected"]["ShippingServiceCost"]);
         $basket = $order->getBasket();
         if ($basket) {
             $shipmentItemCollection = $shipment->getShipmentItemCollection();
             $basketItems = $basket->getBasketItems();
             foreach ($basketItems as $basketItem) {
                 $shipmentItem = $shipmentItemCollection->createItem($basketItem);
                 $shipmentItem->setQuantity($basketItem->getField('QUANTITY'));
             }
         }
         // todo: delivery price changed. Probably bug.
         $shipment->setField('BASE_PRICE_DELIVERY', $orderEbay["ShippingServiceSelected"]["ShippingServiceCost"]);
     } else {
         Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_SHIPPING_ERROR", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_NOT_MAPPED_SHIPPING", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"], "#EBAY_SHIPPING#" => $orderEbay["ShippingServiceSelected"]["ShippingService"])), $this->siteId);
         return 0;
     }
     // order status
     if (strlen($settings[$this->siteId]["STATUS_MAP"][$orderEbay["OrderStatus"]]) > 0) {
         switch ($settings[$this->siteId]["STATUS_MAP"][$orderEbay["OrderStatus"]]) {
             /* flags */
             case "CANCELED":
                 if (!$order->setField("CANCELED", "Y")) {
                     Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_CANCELING_ERROR", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_CANCEL_ERROR", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"])), $this->siteId);
                 }
                 break;
             case "PAYED":
                 $payments = $order->getPaymentCollection();
                 foreach ($payments as $payment) {
                     $payment->setPaid("Y");
                 }
                 break;
             case "ALLOW_DELIVERY":
                 // we suggest that only one shipment exists
                 $shipments = $order->getShipmentCollection();
                 foreach ($shipments as $shipment) {
                     if (!$shipment->isSystem()) {
                         if (!$shipment->allowDelivery()) {
                             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_ALLOW_DELIVERY_ERROR", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_ALLOW_DELIVERY_ERROR", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"])), $this->siteId);
                         }
                     }
                 }
                 break;
             case "DEDUCTED":
                 $shipments = $order->getShipmentCollection();
                 foreach ($shipments as $shipment) {
                     if (!$shipment->isSystem()) {
                         if (!$shipment->setField('DEDUCTED', 'Y')) {
                             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_DEDUCTIOING_ERROR", $orderEbay["ExtendedOrderID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_DEDUCT_ERROR", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"])), $this->siteId);
                         }
                     }
                 }
                 break;
                 /* statuses */
             /* statuses */
             default:
                 $res = $order->setField("STATUS_ID", $settings[$this->siteId]["STATUS_MAP"][$orderEbay["OrderStatus"]]);
                 /** @var \Bitrix\Sale\Result $res */
                 if (!$res->isSuccess()) {
                     Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_CHANGE_STATUS_ERROR", $orderEbay["OrderLineItemID"], Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_SET_STATUS_ERROR", array("#ORDER_ID#" => $orderEbay["ExtendedOrderID"], "#STATUS#" => $orderEbay["OrderStatus"])), $this->siteId);
                 }
         }
     }
     $order->setField("PRICE", $orderEbay["Total"]);
     $order->setField("XML_ID", Ebay::TRADING_PLATFORM_CODE . "_" . $orderEbay["ExtendedOrderID"]);
     $res = $order->save();
     if (!$res->isSuccess()) {
         foreach ($res->getErrors() as $error) {
             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_SAVE_ERROR", $orderEbay["ExtendedOrderID"], print_r($error->getMessage(), true), $this->siteId);
         }
     } else {
         $bitrixOrderId = $order->getId();
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_ORDER_CREATED", $bitrixOrderId, Loc::getMessage("SALE_TP_EBAY_FDPO_ORDER_SAVED", array("#ORDER_ID#" => $bitrixOrderId)), $this->siteId);
         \CSaleMobileOrderPush::send("ORDER_CREATED", array("ORDER_ID" => $bitrixOrderId));
         $res = OrderTable::add(array("ORDER_ID" => $bitrixOrderId, "TRADING_PLATFORM_ID" => $ebay->getId(), "EXTERNAL_ORDER_ID" => $orderEbay["ExtendedOrderID"], "PARAMS" => array("ORDER_LINES" => $orderLineItemsIds, "ORDER_ID" => $orderEbay["OrderID"])));
         if (!$res->isSuccess()) {
             foreach ($res->getErrors() as $error) {
                 Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_PROCESSOR_ORDER_DELIVERY_SAVE_ERROR", $orderEbay["ExtendedOrderID"], $error->getMessage(), $this->siteId);
             }
         }
     }
     // send confirmation
     if ($bitrixOrderId > 0 && !empty($orderLineItemsIds)) {
         $ebayFeed = \Bitrix\Sale\TradingPlatform\Ebay\Feed\Manager::createFeed("ORDER_ACK", $this->siteId);
         $sourceData = array();
         foreach ($orderLineItemsIds as $id) {
             $sourceData[] = array("ORDER_ID" => $orderEbay["OrderID"], "ORDER_LINE_ITEM_ID" => $id);
         }
         $ebayFeed->setSourceData(array($sourceData));
         $ebayFeed->processData();
     }
     return $bitrixOrderId;
 }
예제 #13
0
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
use Bitrix\Main\Localization\Loc;
use Bitrix\Sale\TradingPlatform\Helper;
Loc::loadMessages(__FILE__);
/** @var CMain $APPLICATION */
if ($APPLICATION->GetGroupRight("sale") < "W") {
    $APPLICATION->AuthForm(GetMessage("SALE_ACCESS_DENIED"));
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid()) {
    $APPLICATION->AuthForm(Loc::getMessage("SALE_ACCESS_DENIED"));
}
if (!\Bitrix\Main\Loader::includeModule('sale')) {
    $arResult["ERROR"] = Loc::getMessage("SALE_MODULE_NOT_INSTALLED");
}
$ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
if (!$ebay->isActive()) {
    LocalRedirect("/bitrix/admin/sale_ebay.php?lang=" . LANG . "&back_url=" . urlencode($APPLICATION->GetCurPageParam()));
}
$errorMsg = "";
$bSaved = false;
$siteList = array();
$defaultSite = "";
$rsSites = CSite::GetList($by = "sort", $order = "asc", array("ACTIVE" => "Y"));
while ($arRes = $rsSites->Fetch()) {
    $siteList[$arRes['ID']] = $arRes['NAME'];
    if ($arRes["DEF"] == "Y") {
        $defaultSite = $arRes['ID'];
    }
}
if (isset($_POST["SITE_ID"]) && array_key_exists($_POST["SITE_ID"], $siteList)) {
예제 #14
0
파일: ebay.php 프로젝트: Satariall/izurit
		<td width="60%">
			<input id="SALE_EBAY_SETTINGS_API_TOKEN_EXP" type="text" name="EBAY_SETTINGS[API][AUTH_TOKEN_EXP]" size="20" value="<?php 
    echo isset($siteSettings["API"]["AUTH_TOKEN_EXP"]) ? $siteSettings["API"]["AUTH_TOKEN_EXP"] : "";
    ?>
" disabled>
			<input type="hidden" name="EBAY_SETTINGS[API][SITE_ID]" value="215">
		</td>
	</tr>
	<tr>
		<td width="40%"><span>&nbsp;</span></td>
		<td width="60%">
			<input type="button" value="<?php 
    echo Loc::getMessage("SALE_EBAY_GET_TOKEN");
    ?>
" onclick="window.open('<?php 
    echo Ebay::getApiTokenUrl();
    ?>
', 'gettingToken');">
			<script>BX.Sale.EbayAdmin.addApiTokenListener({
					messageOk: "<?php 
    echo Loc::getMessage('SALE_EBAY_GET_API_TOKEN_OK');
    ?>
",
					messageError: "<?php 
    echo Loc::getMessage('SALE_EBAY_GET_API_TOKEN_ERROR');
    ?>
"
				});
			</script>

		</td>
예제 #15
0
파일: policy.php 프로젝트: Satariall/izurit
 protected function sendRequest($operationName, $data)
 {
     $this->http->setHeader("X-EBAY-SOA-CONTENT-TYPE", "text/xml");
     $this->http->setHeader("X-EBAY-SOA-GLOBAL-ID", "EBAY-RU");
     $this->http->setHeader("X-EBAY-SOA-SERVICE-NAME", "SellerProfilesManagementService");
     $this->http->setHeader("X-EBAY-SOA-OPERATION-NAME", $operationName);
     //addSellerProfile getSellerProfiles
     $this->http->setHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT", "XML");
     $this->http->setHeader("X-EBAY-SOA-RESPONSE-DATA-FORMAT", "XML");
     $this->http->setHeader("X-EBAY-SOA-SECURITY-TOKEN", $this->authToken);
     if (strtolower(SITE_CHARSET) != 'utf-8') {
         $data = Encoding::convertEncodingArray($data, SITE_CHARSET, 'UTF-8');
     }
     $result = $this->http->post(self::URL, $data);
     $errors = $this->http->getError();
     if (!$result && !empty($errors)) {
         $strError = "";
         foreach ($errors as $errorCode => $errMes) {
             $strError .= $errorCode . ": " . $errMes;
         }
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_POLICY_REQUEST_ERROR", $operationName, $strError, $this->siteId);
     } else {
         $status = $this->http->getStatus();
         if ($status != 200) {
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_POLICY_REQUEST_HTTP_ERROR", $operationName, 'HTTP error code: ' . $status, $this->siteId);
         }
         if (strtolower(SITE_CHARSET) != 'utf-8') {
             $result = Encoding::convertEncodingArray($result, 'UTF-8', SITE_CHARSET);
         }
     }
     return $result;
 }
예제 #16
0
파일: agent.php 프로젝트: Satariall/izurit
 /**
  * @param $feedType
  * @param $siteId
  * @param $interval
  * @param bool|false $once
  * @return bool|int
  * @throws ArgumentNullException
  * @throws ArgumentOutOfRangeException
  */
 public static function add($feedType, $siteId, $interval, $once = false)
 {
     if ($interval <= 0) {
         return 0;
     }
     if (empty($siteId)) {
         throw new ArgumentNullException('siteId');
     }
     $siteId = \EscapePHPString($siteId);
     if ($feedType == "ORDER") {
         $sort = 50;
     } elseif ($feedType == "PRODUCT") {
         $sort = 100;
     } elseif ($feedType == "INVENTORY" || $feedType == "IMAGE") {
         $sort = 150;
     } else {
         throw new ArgumentOutOfRangeException('feedType');
     }
     $intervalSeconds = $interval * 60;
     $timeToStart = ConvertTimeStamp(strtotime(date('Y-m-d H:i:s', time() + $intervalSeconds)), 'FULL');
     $result = \CAgent::AddAgent(self::createAgentNameForAdd($feedType, $siteId, $once), 'sale', "N", $interval * 60, $timeToStart, "Y", $timeToStart, $sort);
     Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_AGENT_ADDING_RESULT", $feedType, "Feed: " . $feedType . ", site: " . $siteId . ", interval: " . $interval . " once: " . ($once ? 'true' : 'false') . " agentId: '" . $result . "'", $siteId);
     return $result;
 }
예제 #17
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;
 }
예제 #18
0
    public function ShowTabSection($divName, $arArgs, $bVarsFromForm)
    {
        $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
        $settings = $ebay->getSettings();
        if (empty($settings[$arArgs["IBLOCK"]["LID"]])) {
            return '';
        }
        $siteSettings = $settings[$arArgs["IBLOCK"]["LID"]];
        global $APPLICATION;
        //categories
        $resultHtml = '<tr>' . '<td width="20%" valign="top">' . Loc::getMessage("SALE_EBAY_CSTH_CATEGORY") . ':</td>' . '<td width="80%">';
        $catMapRes = \Bitrix\Sale\TradingPlatform\MapTable::getList(array("filter" => array("ENTITY_ID" => \Bitrix\Sale\TradingPlatform\Ebay\MapHelper::getCategoryEntityId($arArgs["IBLOCK"]["ID"]), "VALUE_INTERNAL" => $arArgs["ID"])));
        $arMapRes = $catMapRes->fetch();
        $params = array("TOP_CATEGORY_SELECT_NAME" => "SALE[EBAY][TOP_CATEGORY]", "CATEGORY_INPUT_NAME" => "SALE[EBAY][EBAY_CATEGORY_ID]", "EBAY_CATEGORY_VARIATIONS_SN" => "SALE[EBAY][EBAY_CATEGORY_VARIATIONS]", "BITRIX_CATEGORY_PROPS_SN" => "SALE[EBAY][BITRIX_CATEGORY_PROPS]", "BITRIX_CATEGORY_ID" => $arArgs["ID"], "IBLOCK_ID" => $arArgs["IBLOCK"]["ID"]);
        if (isset($_POST["SALE"]["EBAY"]["EBAY_CATEGORY_ID"])) {
            $params["EBAY_CATEGORY_ID"] = $_POST["SALE"]["EBAY"]["EBAY_CATEGORY_ID"];
        } elseif (isset($arMapRes["VALUE_EXTERNAL"])) {
            $params["EBAY_CATEGORY_ID"] = $arMapRes["VALUE_EXTERNAL"];
        }
        if (isset($_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"]) && isset($_POST["SALE"]["EBAY"]["BITRIX_CATEGORY_PROPS"])) {
            $params["VARIATIONS_VALUES"] = array();
            for ($i = 0, $l = count($_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"]); $i < $l; $i++) {
                $params["VARIATIONS_VALUES"][$_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"][$i]] = $_POST["SALE"]["EBAY"]["BITRIX_CATEGORY_PROPS"][$i];
            }
        }
        ob_start();
        $APPLICATION->IncludeComponent("bitrix:sale.ebay.categories", ".default", $params);
        $resultHtml .= ob_get_contents();
        ob_end_clean();
        $resultHtml .= '</td>' . '</tr>';
        //policies
        $errorMsg = "";
        $policy = null;
        $policyReturn = "";
        $policyPayment = "";
        $policyShipping = "";
        if (isset($_POST["SALE"]["EBAY"]["POLICY"])) {
            if (!empty($_POST["SALE"]["EBAY"]["POLICY"]["RETURN"])) {
                $policyReturn = $_POST["SALE"]["EBAY"]["POLICY"]["RETURN"];
            }
            if (!empty($_POST["SALE"]["EBAY"]["POLICY"]["SHIPPING"])) {
                $policyShipping = $_POST["SALE"]["EBAY"]["POLICY"]["SHIPPING"];
            }
            if (!empty($_POST["SALE"]["EBAY"]["POLICY"]["PAYMENT"])) {
                $policyPayment = $_POST["SALE"]["EBAY"]["POLICY"]["PAYMENT"];
            }
        } elseif (!empty($arMapRes["PARAMS"]["POLICY"])) {
            if (!empty($arMapRes["PARAMS"]["POLICY"]["RETURN"])) {
                $policyReturn = $arMapRes["PARAMS"]["POLICY"]["RETURN"];
            }
            if (!empty($arMapRes["PARAMS"]["POLICY"]["SHIPPING"])) {
                $policyShipping = $arMapRes["PARAMS"]["POLICY"]["SHIPPING"];
            }
            if (!empty($arMapRes["PARAMS"]["POLICY"]["PAYMENT"])) {
                $policyPayment = $arMapRes["PARAMS"]["POLICY"]["PAYMENT"];
            }
        }
        if (strlen($policyReturn) <= 0 && !empty($siteSettings["POLICY"]["RETURN"]["DEFAULT"])) {
            $policyReturn = $siteSettings["POLICY"]["RETURN"]["DEFAULT"];
        }
        if (strlen($policyShipping) <= 0 && !empty($siteSettings["POLICY"]["SHIPPING"]["DEFAULT"])) {
            $policyShipping = $siteSettings["POLICY"]["SHIPPING"]["DEFAULT"];
        }
        if (strlen($policyPayment) <= 0 && !empty($siteSettings["POLICY"]["PAYMENT"]["DEFAULT"])) {
            $policyPayment = $siteSettings["POLICY"]["PAYMENT"]["DEFAULT"];
        }
        if (isset($siteSettings["API"]["AUTH_TOKEN"]) && strlen($siteSettings["API"]["AUTH_TOKEN"]) > 0) {
            $policy = new \Bitrix\Sale\TradingPlatform\Ebay\Policy($siteSettings["API"]["AUTH_TOKEN"], $arArgs["IBLOCK"]["LID"]);
        } else {
            $errorMsg .= "You must set API token first!\n";
        }
        $resultHtml .= '
			<tr></tr><td colspan="2" style="border-top: 2px solid #e0e8ea;">&nbsp;</td></tr>
			<tr>
				<td>' . Loc::getMessage("SALE_EBAY_CSTH_POLICY_RETURN") . ':</span></td>
				<td>
					<select name="SALE[EBAY][POLICY][RETURN]">';
        if ($policy) {
            foreach ($policy->getPoliciesNames(\Bitrix\Sale\TradingPlatform\Ebay\Policy::TYPE_RETURN) as $policyId => $policyName) {
                $resultHtml .= '<option value="' . htmlspecialcharsbx($policyId) . '"' . ($policyReturn == $policyId ? " selected" : "") . '>' . $policyName . '</option>';
            }
        }
        $resultHtml .= '
					</select>
				</td>
			</tr>
			<tr>
				<td>' . Loc::getMessage("SALE_EBAY_CSTH_POLICY_SHIPMENT") . ':</td>
				<td>
					<select name="SALE[EBAY][POLICY][SHIPPING]">';
        if ($policy) {
            foreach ($policy->getPoliciesNames(\Bitrix\Sale\TradingPlatform\Ebay\Policy::TYPE_SHIPPING) as $policyId => $policyName) {
                $resultHtml .= '<option value="' . htmlspecialcharsbx($policyId) . '"' . ($policyShipping == $policyId ? " selected" : "") . '>' . $policyName . '</option>';
            }
        }
        $resultHtml .= '
					</select>
				</td>
			</tr>
			<tr>
				<td>' . Loc::getMessage("SALE_EBAY_CSTH_POLICY_PAYMENT") . ':</td>
				<td>
					<select name="SALE[EBAY][POLICY][PAYMENT]">';
        if ($policy) {
            foreach ($policy->getPoliciesNames(\Bitrix\Sale\TradingPlatform\Ebay\Policy::TYPE_PAYMENT) as $policyId => $policyName) {
                $resultHtml .= '<option value="' . htmlspecialcharsbx($policyId) . '"' . ($policyPayment == $policyId ? " selected" : "") . '>' . $policyName . '</option>';
            }
        }
        $resultHtml .= '	</select>
				</td>
			</tr>
			<tr>
				<td>&nbsp</td><td><a href="http://www.bizpolicy.ebay.ru/businesspolicy/manage?totalPages=1">' . Loc::getMessage('SALE_EBAY_CSTH_EDIT_POLICIES') . '</a></td>
			</tr>';
        return $resultHtml;
    }
예제 #19
0
 public function save()
 {
     $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
     $settings = $ebay->getSettings();
     foreach (array('IBLOCK_ID', 'IBLOCK_TYPE_ID', 'MORE_PHOTO_PROP') as $param) {
         foreach ($this->ebaySettings[$this->siteId][$param] as $key => $value) {
             if (strlen($value) <= 0) {
                 unset($this->ebaySettings[$this->siteId][$param][$key]);
             }
         }
         $settings[$this->siteId][$param] = $this->ebaySettings[$this->siteId][$param];
     }
     $result = $ebay->saveSettings($settings);
     $this->ebaySettings = $ebay->getSettings();
     return $result;
 }
예제 #20
0
 /**
  * @param $feedType
  * @param $siteId
  * @param int $timeLimit
  * @return Feed|bool
  * @throws SystemException
  */
 public static function createFeed($feedType, $siteId, $timeLimit = 0)
 {
     $timer = new Timer($timeLimit);
     $feepParams = array("TIMER" => new $timer());
     switch ($feedType) {
         case 'PRODUCT':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Product(array("SITE_ID" => $siteId));
             $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
             break;
         case 'INVENTORY':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Inventory();
             $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
             break;
         case 'ORDER':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Order(array("FEED_TYPE" => "order", "SCHEMA_FILE_NAME" => "Order.xsd", "SITE_ID" => $siteId));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Order();
             $feepParams["DATA_PROCESSOR"] = new Data\Processors\Order(array("SITE_ID" => $siteId));
             break;
         case 'ORDER_ACK':
             $feepParams["DATA_SOURCE"] = new Data\Sources\SimpleArray();
             $feepParams["DATA_CONVERTER"] = new Data\Converters\OrderAck();
             $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
             break;
         case 'SHIPMENT':
             $feepParams["DATA_SOURCE"] = new Data\Sources\SimpleArray();
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Shipment();
             $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
             break;
         case 'IMAGE':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Product(array("SITE_ID" => $siteId));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Image(array("SITE_ID" => $siteId));
             $feepParams["DATA_PROCESSOR"] = self::createSftpQueue($feedType, $siteId, $timer);
             break;
         case 'PROCESS_RESULT':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Results(array("SITE_ID" => $siteId, "REMOTE_PATH_TMPL" => "/store/##FEED_TYPE##/log/##UPLOAD_DATE##", "FILTER" => array("PROCESSING_REQUEST_ID" => "")));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\ProcessResult();
             $feepParams["DATA_PROCESSOR"] = new Data\Processors\ProcessResult();
             break;
         case 'RESULTS':
             $feepParams["DATA_SOURCE"] = new Data\Sources\Results(array("SITE_ID" => $siteId, "REMOTE_PATH_TMPL" => "/store/##FEED_TYPE##/output/##UPLOAD_DATE##", "FILTER" => array("RESULTS" => "")));
             $feepParams["DATA_CONVERTER"] = new Data\Converters\Results();
             $feepParams["DATA_PROCESSOR"] = new Data\Processors\Results(array("SITE_ID" => $siteId));
             break;
         default:
             throw new SystemException("Unknown type of feed \"" . $feedType . "\". " . __METHOD__);
             break;
     }
     $feed = new Feed($feepParams);
     Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_FEED_CREATED", $feedType, "Feed: " . $feedType . ", site: " . $siteId, $siteId);
     return $feed;
 }
예제 #21
0
파일: helper.php 프로젝트: Satariall/izurit
 /**
  * @param string $siteId
  * @return \Bitrix\Sale\TradingPlatform\Sftp
  * @throws \Bitrix\Main\ArgumentNullException
  */
 public static function getSftp($siteId)
 {
     if (strlen($siteId) <= 0) {
         throw new ArgumentNullException("siteId");
     }
     static $sftp = array();
     if (!isset($sftp[$siteId])) {
         $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
         $settings = $ebay->getSettings();
         $sftp[$siteId] = new Sftp($settings[$siteId]["SFTP_LOGIN"], $settings[$siteId]["SFTP_PASS"]);
     }
     return $sftp[$siteId];
 }