40 $iblockId = (int)$fields[
'iblockId'];
41 $name = $fields[
'name'];
50 if (!Loader::includeModule(
'highloadblock') || !Loader::includeModule(
'iblock'))
57 if (!\CIBlockSectionRights::UserHasRightTo($iblockId, 0,
'section_element_bind'))
59 $this->
addError(
new Error(
"User has no permissions to create product"));
64 $propertySettings = PropertyTable::getList([
65 'select' => [
'ID',
'USER_TYPE_SETTINGS'],
67 '=IBLOCK_ID' => $iblockId,
69 '=CODE' =>
'BRAND_FOR_FACEBOOK',
76 if (!$propertySettings)
81 $propertySettings[
'USER_TYPE_SETTINGS'] = (
82 $userTypeSettings = CheckSerializedData($propertySettings[
'USER_TYPE_SETTINGS'])
83 ? unserialize($propertySettings[
'USER_TYPE_SETTINGS'], [
'allowed_classes' =>
false])
87 if (empty($userTypeSettings[
'TABLE_NAME']))
92 $table = HL\HighloadBlockTable::getList(
94 'select' => array(
'TABLE_NAME',
'NAME',
'ID'),
95 'filter' => array(
'=TABLE_NAME' => $userTypeSettings[
'TABLE_NAME'])
99 $xmlId = Random::getString(16);
100 $brandEntity = HL\HighloadBlockTable::compileEntity($table);
101 $brandEntityClass = $brandEntity->getDataClass();
102 $resultAdd = $brandEntityClass::add([
104 'UF_XML_ID' => $xmlId,
107 if (!$resultAdd->isSuccess())
109 $this->
addErrors($resultAdd->getErrors());