Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
maphelper.php
1<?php
2
4
9
10
17{
22 public static function getCategoryEntityCode($iblockId)
23 {
24 return "CATEGORY_IBLOCK_".$iblockId;
25 }
26
32 public static function getCategoryVariationEntityCode($iblockId, $ebayCategoryId)
33 {
34 return "CATEGORY_VAR_".$iblockId."_".$ebayCategoryId;
35 }
36
41 public static function getDeliveryEntityCode($siteId)
42 {
43 return "DELIVERY_".$siteId;
44 }
45
50 public static function getDeliveryEntityId($siteId)
51 {
52 $deliveryEntCode = self::getDeliveryEntityCode($siteId);
53 return self::getMapEntityId($deliveryEntCode);
54 }
55
60 public static function getCategoryEntityId($iblockId)
61 {
62 $catMapEntCode = self::getCategoryEntityCode($iblockId);
63 return self::getMapEntityId($catMapEntCode);
64 }
65
71 public static function getCategoryVariationEntityId($iblockId, $ebayCategoryId)
72 {
73 $mapEntityCode = self::getCategoryVariationEntityCode($iblockId, $ebayCategoryId);
74 return self::getMapEntityId($mapEntityCode);
75 }
76
82 protected static function getMapEntityId($mapEntityCode)
83 {
84 $result = 0;
85 $ebay = Ebay::getInstance();
86
87 $fields = array(
88 "TRADING_PLATFORM_ID" => $ebay->getId(),
89 "CODE" => $mapEntityCode
90 );
91
92 $catMapVarEntRes = MapEntityTable::getList(array(
93 "filter" => $fields
94 ));
95
96 if($arCatVarMapEnt = $catMapVarEntRes->fetch())
97 {
98 $result = $arCatVarMapEnt["ID"];
99 }
100 else
101 {
102 $addRes = MapEntityTable::add($fields);
103
104 if($addRes->isSuccess())
105 $result = $addRes->getId();
106 }
107
108 if($result <= 0)
109 throw new SystemException("Can' t get map entity id for code: ".$mapEntityCode.".");
110
111 return $result;
112 }
113
119 public function getBitrixDeliveryIds(array $ebayDelivery, $siteId)
120 {
121 $result = array();
122 $deliveryEntId = self::getDeliveryEntityId($siteId);
123
124 $deliveryRes = MapTable::getList(array(
125 "filter" => array(
126 "ENTITY_ID" => $deliveryEntId,
127 "VALUE_EXTERNAL" => $ebayDelivery
128 )
129 ));
130
131 while($arMapRes = $deliveryRes->fetch())
132 $result[$arMapRes["VALUE_EXTERNAL"]] = $arMapRes["VALUE_INTERNAL"];
133
134 return $result;
135 }
136}
static getCategoryVariationEntityId($iblockId, $ebayCategoryId)
Definition maphelper.php:71
static getCategoryVariationEntityCode($iblockId, $ebayCategoryId)
Definition maphelper.php:32
getBitrixDeliveryIds(array $ebayDelivery, $siteId)