45 $catInfo = $this->
getItems(array(
"DetailLevel" =>
"ReturnAll"));
46 $existCategoriesList = array();
48 $res = CategoryTable::getList(array(
49 "select" => array(
"ID",
"CATEGORY_ID")
52 while($category = $res->fetch())
53 $existCategoriesList[$category[
"CATEGORY_ID"]] = $category[
"ID"];
55 if(isset($catInfo[
"CategoryArray"][
"Category"]))
59 foreach($categories as $category)
62 "CATEGORY_ID" => $category[
"CategoryID"],
63 "LEVEL" => $category[
"CategoryLevel"],
64 "NAME" => $category[
"CategoryName"],
65 "PARENT_ID" => $category[
"CategoryParentID"]
68 if(array_key_exists($category[
"CategoryID"], $existCategoriesList))
71 $result = CategoryTable::add($fields);
73 if($result->isSuccess())
80 return $refreshedCount;
99 $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
100 $settings = $ebay->getSettings();
101 $iblocksIds = array();
104 foreach($settings[$this->siteId][
"IBLOCK_ID"] as $iblockId)
105 $iblocksIds[] = \Bitrix\Sale\TradingPlatform\Ebay\MapHelper::getCategoryEntityId($iblockId);
107 $catMapRes = \Bitrix\Sale\TradingPlatform\MapTable::getList(array(
109 "ENTITY_ID" => $iblocksIds
113 while($arMapRes = $catMapRes->fetch())
114 $result = $arMapRes[
"VALUE_EXTERNAL"];
124 "CategoryID" => empty($ebayCategoriesIds) ? $this->
getMappedCategories() : $ebayCategoriesIds
127 $specifics = new \SimpleXMLElement($specXml, LIBXML_NOCDATA);
129 foreach($specifics->Recommendations as $categoryRecommendation)
131 foreach($categoryRecommendation->NameRecommendation as $nameRecommendation)
134 "CATEGORY_ID" => $categoryRecommendation->CategoryID->__toString(),
135 "NAME" => $nameRecommendation->Name->__toString()
138 if(isset($nameRecommendation->ValidationRules))
141 if($nameRecommendation->ValidationRules->MinValues)
142 $fields[
"MIN_VALUES"] = $nameRecommendation->ValidationRules->MinValues->__toString();
144 $fields[
"MIN_VALUES"] = 0;
146 if($nameRecommendation->ValidationRules->MinValues)
147 $fields[
"MAX_VALUES"] = $nameRecommendation->ValidationRules->MaxValues->__toString();
149 $fields[
"MAX_VALUES"] = 0;
151 $fields[
"REQUIRED"] = intval($fields[
"MIN_VALUES"]) > 0 ?
"Y" :
"N";
152 $fields[
"SELECTION_MODE"] = $nameRecommendation->ValidationRules->SelectionMode->__toString();
153 $fields[
"ALLOWED_AS_VARIATION"] = $nameRecommendation->ValidationRules->VariationSpecifics->__toString() ==
"Enabled" ?
"Y" :
"N";
154 $fields[
"HELP_URL"] = $nameRecommendation->ValidationRules->HelpURL->__toString();
157 if(isset($nameRecommendation->ValueRecommendation))
161 foreach($nameRecommendation->ValueRecommendation as $valueRecommendation)
162 $values[] = $valueRecommendation->Value->__toString();
164 $fields[
"VALUE"] = $values;
167 if(mb_strtolower(SITE_CHARSET) !=
'utf-8')
168 $fields = \Bitrix\Main\Text\Encoding::convertEncodingArray($fields,
'UTF-8', SITE_CHARSET);
170 $res = CategoryVariationTable::getList(array(
172 "CATEGORY_ID" => $fields[
"CATEGORY_ID"],
173 "NAME" => $fields[
"NAME"]
175 "select" => array(
"ID")
178 if($savedVar = $res->fetch())
179 $result = CategoryVariationTable::update($savedVar[
"ID"], $fields);
181 $result = CategoryVariationTable::add($fields);
183 if($result->isSuccess())
190 return $refreshedCount;