33 if(empty($this->ebayCategories))
34 throw new SystemException(
'Can\'t recieve categories for ebay. Product id: '.$data[
"ID"].
', product categories ids: '.implode(
', '.$data[
"CATEGORIES"]));
36 $this->attributesList = $this->
getAttributesList($data[
"IBLOCK_ID"], $this->ebayCategories);
38 $this->bitrixCategories = $data[
"CATEGORIES"];
40 if(isset($data[
"OFFERS"]) && is_array($data[
"OFFERS"]) && !empty($data[
"OFFERS"]))
44 foreach($data[
"OFFERS"] as $offer)
89 $this->variationsVector = array_diff_key($this->attributesList, $this->attributesItem);
91 $result =
"\t<Listing>\n";
92 $result .=
"\t\t<ProductVariationGroup>\n";
93 $result .=
"\t\t\t<Country>RU</Country>\n";
94 $result .=
"\t\t\t<GroupId>".$data[
"IBLOCK_ID"].
"_".$data[
"ID"].
"</GroupId>\n";
96 if(is_array($this->variationsVector) && !empty($this->variationsVector))
98 $result .=
"\t\t\t<VariationVector>\n";
100 foreach($this->variationsVector as $ebayAttributeName => $bitrixPropId)
101 $result .=
"\t\t\t\t<Name>".\CDataXML::xmlspecialchars($ebayAttributeName).
"</Name>\n";
103 $result .=
"\t\t\t</VariationVector>\n";
106 $result .=
"\t\t\t<Categories>\n";
108 foreach($this->ebayCategories as $category)
109 $result .=
"\t\t\t\t<Category Type=\"eBayLeafCategory\">".$category.
"</Category>\n";
111 $result .=
"\t\t\t</Categories>\n";
112 $result .=
"\t\t\t<SharedProductInformation>\n";
113 $result .=
"\t\t\t<Title>".\CDataXML::xmlspecialchars($data[
"NAME"]).
"</Title>\n";
114 $result .=
"\t\t\t<Description>\n";
115 $result .=
"\t\t\t\t<ProductDescription>\n";
116 $result .=
"<![CDATA[\n";
117 $result .= $data[
"~PREVIEW_TEXT"] <>
'' ? $data[
"~PREVIEW_TEXT"] : $data[
"~DETAIL_TEXT"].
"\n";
119 $result .=
"</ProductDescription>\n";
120 $result .=
"\t\t\t</Description>\n";
122 if(!empty($this->attributesItem))
124 $result .=
"\t\t\t<Attributes>\n";
126 foreach($this->attributesItem as $attrName => $attrValue)
128 if(is_array($attrValue))
130 $attrValue = current($attrValue);
133 $result .=
"\t\t\t\t<Attribute Name=\"".\CDataXML::xmlspecialchars($attrName).
"\">".\CDataXML::xmlspecialchars($attrValue).
"</Attribute>\n";
136 $result .=
"\t\t\t</Attributes>\n";
139 $result .=
"\t\t\t<PictureUrls>\n";
140 $result .=
"\t\t\t\t<PictureUrl>".($data[
"DETAIL_PICTURE_URL"] <>
'' ? $data[
"DETAIL_PICTURE_URL"] : $data[
"PREVIEW_PICTURE_URL"] ).
"</PictureUrl>\n";
141 $result .=
"\t\t\t</PictureUrls>\n";
142 $result .=
"<ConditionInfo>
143 <Condition>NEW</Condition>
145 $result .=
"\t\t\t</SharedProductInformation>\n";
146 reset($this->ebayCategories);
147 $result .= $this->
getListingDetails($data[
"IBLOCK_ID"], current($this->ebayCategories));
148 $result .=
"\t\t</ProductVariationGroup>\n";
149 $result .=
"\t</Listing>\n";
186 $result =
"\t<Listing>\n";
187 $result .=
"\t\t<Product>\n";
188 $result .=
"\t\t\t<SKU>".$data[
"IBLOCK_ID"].
"_".$data[
"ID"].
"</SKU>\n";
189 $result .=
"\t\t\t<ProductInformation>\n";
190 $result .=
"\t\t\t\t<Country>RU</Country>\n";
191 $result .=
"\t\t\t\t<Title>".\CDataXML::xmlspecialchars($data[
"NAME"]).
"</Title>\n";
192 $result .=
"\t\t\t\t<Description>\n";
193 $result .=
"\t\t\t\t\t<ProductDescription>\n";
194 $result .=
"<![CDATA[\n";
195 $result .= $data[
"~PREVIEW_TEXT"] <>
'' ? $data[
"~PREVIEW_TEXT"] : $data[
"~DETAIL_TEXT"].
"\n";
197 $result .=
"</ProductDescription>\n";
198 $result .=
"\t\t\t\t</Description>\n";
199 $result .=
"<ConditionInfo>
200 <Condition>NEW</Condition>
203 if(!empty($this->attributesItem))
205 $result .=
"\t\t\t\t<Attributes>\n";
207 foreach($this->attributesItem as $attrName => $attrValue)
209 if(is_array($attrValue))
211 $attrValue = current($attrValue);
214 $result .=
"\t\t\t\t\t<Attribute Name=\"".\CDataXML::xmlspecialchars($attrName).
"\">".\CDataXML::xmlspecialchars($attrValue).
"</Attribute>\n";
217 $result .=
"\t\t\t\t</Attributes>\n";
220 $result .=
"\t\t\t\t<PictureUrls>\n";
221 $result .=
"\t\t\t\t\t<PictureUrl>".($data[
"DETAIL_PICTURE_URL"] <>
'' ? $data[
"DETAIL_PICTURE_URL"] : $data[
"PREVIEW_PICTURE_URL"] ).
"</PictureUrl>\n";
222 $result .=
"\t\t\t\t</PictureUrls>\n";
223 $result .=
"\t\t\t\t<Categories>\n";
225 foreach($this->ebayCategories as $category)
226 $result .=
"\t\t\t\t\t<Category Type=\"eBayLeafCategory\">".$category.
"</Category>\n";
228 $result .=
"\t\t\t\t</Categories>\n";
229 $result .=
"\t\t\t</ProductInformation>\n";
230 $result .=
"\t\t</Product>\n";
231 reset($this->ebayCategories);
232 $result .= $this->
getListingDetails($data[
"IBLOCK_ID"], current($this->ebayCategories));
233 $result .=
"\t</Listing>\n";
240 $result =
"\t\t<ListingDetails>\n";
242 if(!empty($policy[
"RETURN"]))
243 $result .=
"\t\t\t<ReturnPolicy>".\CDataXML::xmlspecialchars($policy[
"RETURN"]).
"</ReturnPolicy>\n";
245 if(!empty($policy[
"SHIPPING"]))
246 $result .=
"\t\t\t<ShippingPolicy>".\CDataXML::xmlspecialchars($policy[
"SHIPPING"]).
"</ShippingPolicy>\n";
248 if(!empty($policy[
"PAYMENT"]))
249 $result .=
"\t\t\t<PaymentPolicy>".\CDataXML::xmlspecialchars($policy[
"PAYMENT"]).
"</PaymentPolicy>\n";
251 $result .=
"\t\t</ListingDetails>\n";
306 static $entitiesIds = [];
308 if (empty($entitiesIds[$iblockId]))
310 $res = \Bitrix\Sale\TradingPlatform\Ebay\MapHelper::getCategoryEntityId($iblockId);
317 $entitiesIds[$iblockId] = $res;
320 static $params = array();
322 if (!isset($params[$iblockId]))
324 $params[$iblockId] = [];
326 $catRes = \Bitrix\Sale\TradingPlatform\MapTable::getList([
328 '=ENTITY_ID' => $entitiesIds[$iblockId],
332 while($category = $catRes->fetch())
334 if ((
int)$category[
"VALUE_INTERNAL"] > 0)
336 $params[$iblockId][$category[
"VALUE_INTERNAL"]] = $category;
348 if (isset($params[$iblockId][$catId]) && is_array($params[$iblockId][$catId]))
350 $result[] = $params[$iblockId][$catId];
354 $res = \CIBlockSection::GetNavChain($iblockId, $catId, [
'ID'],
true);
355 foreach ($res as $row)
357 $id = (int)$row[
'ID'];
358 if (isset($params[$iblockId][$id]) && is_array($params[$iblockId][$id]))
360 $result[] = $params[$iblockId][$id];
368 $result = $params[$iblockId];
376 static $result = array();
378 if(!isset($result[$ebayCategory]))
380 $ebay = \Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance();
381 $settings = $ebay->getSettings();
383 $policyReturnId =
"";
384 $policyPaymentId =
"";
385 $policyShippingId =
"";
386 $result[$ebayCategory] = array();
390 if($categoryParams[
"VALUE_EXTERNAL"] != $ebayCategory)
393 if(!empty($categoryParams[
"PARAMS"][
"POLICY"]))
395 if(!empty($categoryParams[
"PARAMS"][
"POLICY"][
"RETURN"]))
396 $policyReturnId = $categoryParams[
"PARAMS"][
"POLICY"][
"RETURN"];
398 if(!empty($categoryParams[
"PARAMS"][
"POLICY"][
"SHIPPING"]))
399 $policyShippingId = $categoryParams[
"PARAMS"][
"POLICY"][
"SHIPPING"];
401 if(!empty($categoryParams[
"PARAMS"][
"POLICY"][
"PAYMENT"]))
402 $policyPaymentId = $categoryParams[
"PARAMS"][
"POLICY"][
"PAYMENT"];
405 if($policyReturnId ==
'' && !empty($siteSettings[
"POLICY"][
"RETURN"][
"DEFAULT"]))
406 $policyReturnId = $siteSettings[
"POLICY"][
"RETURN"][
"DEFAULT"];
408 if($policyShippingId ==
'' && !empty($siteSettings[
"POLICY"][
"SHIPPING"][
"DEFAULT"]))
409 $policyShippingId = $siteSettings[
"POLICY"][
"SHIPPING"][
"DEFAULT"];
411 if($policyPaymentId ==
'' && !empty($siteSettings[
"POLICY"][
"PAYMENT"][
"DEFAULT"]))
412 $policyPaymentId = $siteSettings[
"POLICY"][
"PAYMENT"][
"DEFAULT"];
414 if($policyReturnId !=
"" && !empty($siteSettings[
"POLICY"][
"RETURN"][
"LIST"][$policyReturnId]))
415 $result[$ebayCategory][
"RETURN"] = $siteSettings[
"POLICY"][
"RETURN"][
"LIST"][$policyReturnId];
417 if($policyShippingId !=
"" && !empty($siteSettings[
"POLICY"][
"SHIPPING"][
"LIST"][$policyShippingId]))
418 $result[$ebayCategory][
"SHIPPING"] = $siteSettings[
"POLICY"][
"SHIPPING"][
"LIST"][$policyShippingId];
420 if($policyPaymentId !=
"" && !empty($siteSettings[
"POLICY"][
"PAYMENT"][
"LIST"][$policyPaymentId]))
421 $result[$ebayCategory][
"PAYMENT"] = $siteSettings[
"POLICY"][
"PAYMENT"][
"LIST"][$policyPaymentId];
427 return $result[$ebayCategory];