6use Bitrix\Main\Entity\EventResult;
7use Bitrix\Main\Entity\Result;
48 $dbRes = TradingPlatformTable::getList([
50 '=CODE' => $this->code,
54 if ($platform = $dbRes->fetch())
56 $this->
isActive = $platform[
"ACTIVE"] ==
"Y";
57 $this->isNeedCatalogSectionsTab = $platform[
"CATALOG_SECTION_TAB_CLASS_NAME"] <>
'';
59 if (is_array($platform[
"SETTINGS"]))
61 $this->settings = $platform[
"SETTINGS"];
65 $this->
id = $platform[
"ID"];
66 $this->fields = $platform;
69 $this->logger =
new Logger($this->logLevel);
86 if (!isset(self::$instances[
$code]))
91 return self::$instances[
$code];
111 return $this->logger->addRecord($level, $type, $itemId, $description);
116 if(!isset($this->fields[$fieldName]))
121 return $this->fields[$fieldName];
157 $res = TradingPlatformTable::update($this->
id, array(
"ACTIVE" =>
"Y"));
159 return $res->isSuccess();
173 $res = TradingPlatformTable::update($this->
id, array(
"ACTIVE" =>
"N"));
181 return $res->isSuccess();
186 $dbRes = TradingPlatformTable::getList([
193 return (
bool)$dbRes->fetch();
198 $eventManager = EventManager::getInstance();
199 $eventManager->registerEventHandler(
201 'ShipmentOnAfterUpdate',
203 '\Bitrix\Sale\TradingPlatform\Helper',
204 'onAfterUpdateShipment'
210 $eventManager = EventManager::getInstance();
211 $eventManager->unRegisterEventHandler(
213 'ShipmentOnAfterUpdate',
215 '\Bitrix\Sale\TradingPlatform\Helper',
216 'onAfterUpdateShipment'
228 $res = TradingPlatformTable::getList(array(
229 'select' => array(
"ID",
"CATALOG_SECTION_TAB_CLASS_NAME"),
231 '!=CODE' => $this->code,
236 while ($arRes = $res->fetch())
238 if ($arRes[
"CATALOG_SECTIONS_TAB_CLASS_NAME"] <>
'')
250 $eventManager = EventManager::getInstance();
251 $eventManager->registerEventHandlerCompatible(
"main",
"OnAdminIBlockSectionEdit",
"sale",
"\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab",
"OnInit");
256 $eventManager = EventManager::getInstance();
257 $eventManager->unRegisterEventHandler(
"main",
"OnAdminIBlockSectionEdit",
"sale",
"\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab",
"OnInit");
275 $result = TradingPlatformTable::update($this->
id, array(
"SETTINGS" =>
$settings));
277 return $result->isSuccess() && $result->getAffectedRowsCount();
309 $res = TradingPlatformTable::add(array(
310 "CODE" => self::TRADING_PLATFORM_CODE,
314 self::$instances[$this->
getCode()] =
new static($this->
getCode());
316 return $res->getId();
327 $res = TradingPlatformTable::delete($this->
getId());
334 unset(self::$instances[$this->
getCode()]);
337 return $res->isSuccess();
353 return static::TRADING_PLATFORM_CODE;