Exemplo n.º 1
0
 public function Check($arArgs)
 {
     if (!isset($_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"]) || !is_array($_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"])) {
         return true;
     }
     $result = true;
     $categoriesVarResult = CategoryVariationTable::getList(array('select' => array('ID', 'NAME', 'REQUIRED'), 'filter' => array("=CATEGORY_ID" => $_POST["SALE"]["EBAY"]["EBAY_CATEGORY_ID"])));
     while ($var = $categoriesVarResult->fetch()) {
         if ($var['REQUIRED'] == 'Y') {
             if (!in_array($var["ID"], $_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"])) {
                 $result = false;
                 break;
             }
             $variationIdx = array_search($var["ID"], $_POST["SALE"]["EBAY"]["EBAY_CATEGORY_VARIATIONS"]);
             if ($variationIdx === false || !isset($_POST["SALE"]["EBAY"]["BITRIX_CATEGORY_PROPS"][$variationIdx]) || strlen($_POST["SALE"]["EBAY"]["BITRIX_CATEGORY_PROPS"][$variationIdx]) <= 0) {
                 $result = false;
                 break;
             }
         }
     }
     if (!$result) {
         throw new SystemException("All required variations of category must be filled!");
     }
     return $result;
 }
Exemplo n.º 2
0
 protected function getEbayCategoryAttrName($ebeyAttributeId)
 {
     $res = CategoryVariationTable::getById($ebeyAttributeId);
     if ($category = $res->fetch()) {
         $result = $category["NAME"];
     } else {
         $result = "";
     }
     return $result;
 }
Exemplo n.º 3
0
}
$siteSettings = $settings[$SITE_ID];
unset($settings);
$ebayCategoriesCount = 0;
$ebayCategoriesUpdateDate = "";
$res = \Bitrix\Sale\TradingPlatform\Ebay\CategoryTable::getList(array("select" => array("CNT", "LAST_UPDATE"), "runtime" => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'), new \Bitrix\Main\Entity\ExpressionField('LAST_UPDATE', 'MAX(LAST_UPDATE)'))));
if ($cat = $res->fetch()) {
    if (!empty($cat["CNT"])) {
        $ebayCategoriesCount = $cat["CNT"];
    }
    if (!empty($cat["LAST_UPDATE"])) {
        $ebayCategoriesUpdateDate = $cat["LAST_UPDATE"]->toString();
    }
}
$ebayCategoriesVars = 0;
$res = \Bitrix\Sale\TradingPlatform\Ebay\CategoryVariationTable::getList(array("select" => array("CNT"), "runtime" => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'))));
if ($var = $res->fetch()) {
    $ebayCategoriesVars = $var["CNT"];
}
$defaultFeedIntervals = \Bitrix\Sale\TradingPlatform\Helper::getDefaultFeedIntervals();
$res = \Bitrix\Sale\TradingPlatform\Ebay\Feed\ResultsTable::getList(array("select" => array("FEED_TYPE", "MAX_UPLOAD_TIME"), "group" => array("FEED_TYPE"), "runtime" => array(new \Bitrix\Main\Entity\ExpressionField('MAX_UPLOAD_TIME', 'MAX(UPLOAD_TIME)'))));
$results = array();
while ($lastUpdates = $res->fetch()) {
    $results[$lastUpdates["FEED_TYPE"]] = $lastUpdates["MAX_UPLOAD_TIME"];
}
$filter = array("LOGIC" => "OR");
foreach ($results as $feedType => $uploadTime) {
    $filter[] = array("FEED_TYPE" => $feedType, "UPLOAD_TIME" => $uploadTime);
}
$res = \Bitrix\Sale\TradingPlatform\Ebay\Feed\ResultsTable::getList(array('filter' => $filter));
$results = array();
Exemplo n.º 4
0
 public function refreshVariationsTableData(array $ebayCategoriesIds = array())
 {
     $refreshedCount = 0;
     $specXml = $this->getItemSpecifics(array("CategoryID" => empty($ebayCategoriesIds) ? $this->getMappedCategories() : $ebayCategoriesIds));
     $specifics = new \SimpleXMLElement($specXml, LIBXML_NOCDATA);
     foreach ($specifics->Recommendations as $categoryRecommendation) {
         foreach ($categoryRecommendation->NameRecommendation as $nameRecommendation) {
             $fields = array("CATEGORY_ID" => $categoryRecommendation->CategoryID->__toString(), "NAME" => $nameRecommendation->Name->__toString());
             if (isset($nameRecommendation->ValidationRules)) {
                 if ($nameRecommendation->ValidationRules->MinValues) {
                     $fields["MIN_VALUES"] = $nameRecommendation->ValidationRules->MinValues->__toString();
                 } else {
                     $fields["MIN_VALUES"] = 0;
                 }
                 if ($nameRecommendation->ValidationRules->MinValues) {
                     $fields["MAX_VALUES"] = $nameRecommendation->ValidationRules->MaxValues->__toString();
                 } else {
                     $fields["MAX_VALUES"] = 0;
                 }
                 $fields["REQUIRED"] = intval($fields["MIN_VALUES"]) > 0 ? "Y" : "N";
                 $fields["SELECTION_MODE"] = $nameRecommendation->ValidationRules->SelectionMode->__toString();
                 $fields["ALLOWED_AS_VARIATION"] = $nameRecommendation->ValidationRules->VariationSpecifics->__toString() == "Enabled" ? "Y" : "N";
                 $fields["HELP_URL"] = $nameRecommendation->ValidationRules->HelpURL->__toString();
             }
             if (isset($nameRecommendation->ValueRecommendation)) {
                 $values = array();
                 foreach ($nameRecommendation->ValueRecommendation as $valueRecommendation) {
                     $values[] = $valueRecommendation->Value->__toString();
                 }
                 $fields["VALUE"] = $values;
             }
             if (strtolower(SITE_CHARSET) != 'utf-8') {
                 $fields = \Bitrix\Main\Text\Encoding::convertEncodingArray($fields, 'UTF-8', SITE_CHARSET);
             }
             $res = CategoryVariationTable::getList(array("filter" => array("CATEGORY_ID" => $fields["CATEGORY_ID"], "NAME" => $fields["NAME"]), "select" => array("ID")));
             if ($savedVar = $res->fetch()) {
                 $result = CategoryVariationTable::update($savedVar["ID"], $fields);
             } else {
                 $result = CategoryVariationTable::add($fields);
             }
             if ($result > 0) {
                 $refreshedCount++;
             }
         }
     }
     return $refreshedCount;
 }
Exemplo n.º 5
0
 /**
  * Returns category variations.
  * If variations no found in table get them through API and saves to table.
  * @param string $ebayCategoryId Ebay category id.
  * @param string $siteId Sitte id.
  * @param bool $localInfoOnly Get it from Ebay site if not found in table.
  * @return array
  */
 public static function getEbayCategoryVariations($ebayCategoryId, $siteId, $localInfoOnly = false)
 {
     $result = array();
     $categoriesVarResult = CategoryVariationTable::getList(array('select' => array('ID', 'NAME', 'REQUIRED'), 'order' => array('NAME' => 'ASC'), 'filter' => array("=CATEGORY_ID" => $ebayCategoryId), 'group' => array('NAME')));
     while ($var = $categoriesVarResult->fetch()) {
         $result[$var['ID']] = $var;
     }
     if (empty($result) && !$localInfoOnly) {
         $categories = new \Bitrix\Sale\TradingPlatform\Ebay\Api\Categories($siteId);
         $rfrCount = $categories->refreshVariationsTableData(array($ebayCategoryId));
         if (intval($rfrCount) > 0) {
             $result = self::getEbayCategoryVariations($ebayCategoryId, $siteId, true);
         }
     }
     return $result;
 }