13 private const BRAND_REFERENCE_NAME =
'FacebookBrandReference';
14 private const BRAND_REFERENCE_TABLE_NAME =
'b_catalog_facebook_brand_reference';
15 private const BRAND_PROPERTY_CODE =
'BRAND_FOR_FACEBOOK';
19 self::createProperty();
20 self::createHighLoadBlock();
23 private static function createProperty(): void
26 !Loader::includeModule(
'crm')
27 || !Loader::includeModule(
'iblock')
33 $crmCatalogIblockId = \Bitrix\Crm\Product\Catalog::getDefaultId();
34 $facebookBrandProperty = \CIBlockPropertyTools::getExistProperty(
36 self::BRAND_PROPERTY_CODE
38 if ($facebookBrandProperty)
42 \CIBlockPropertyTools::createProperty(
44 self::BRAND_PROPERTY_CODE,
48 private static function createHighLoadBlock(): void
50 if (!Loader::includeModule(
'highloadblock'))
55 $highLoadBlockResult = Highloadblock\HighloadBlockTable::getList([
57 'NAME' => self::BRAND_REFERENCE_NAME,
58 'TABLE_NAME' => self::BRAND_REFERENCE_TABLE_NAME,
65 if ($highLoadBlockResult->fetch())
71 'NAME' => self::BRAND_REFERENCE_NAME,
72 'TABLE_NAME' => self::BRAND_REFERENCE_TABLE_NAME,
75 $result = Highloadblock\HighloadBlockTable::add($data);
76 if (!$result->isSuccess())
81 $highLoadBlockId = $result->getId();
82 $highLoadData = Highloadblock\HighloadBlockTable::getById($highLoadBlockId)->fetch();
83 Highloadblock\HighloadBlockTable::compileEntity($highLoadData);
86 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
87 'FIELD_NAME' =>
'UF_NAME',
88 'USER_TYPE_ID' =>
'string',
89 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_NAME',
94 'SHOW_IN_LIST' =>
'Y',
95 'EDIT_IN_LIST' =>
'Y',
96 'IS_SEARCHABLE' =>
'Y',
99 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
100 'FIELD_NAME' =>
'UF_FILE',
101 'USER_TYPE_ID' =>
'file',
102 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_FILE',
106 'SHOW_FILTER' =>
'N',
107 'SHOW_IN_LIST' =>
'Y',
108 'EDIT_IN_LIST' =>
'Y',
109 'IS_SEARCHABLE' =>
'Y',
112 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
113 'FIELD_NAME' =>
'UF_LINK',
114 'USER_TYPE_ID' =>
'string',
115 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_LINK',
119 'SHOW_FILTER' =>
'N',
120 'SHOW_IN_LIST' =>
'Y',
121 'EDIT_IN_LIST' =>
'Y',
122 'IS_SEARCHABLE' =>
'Y',
125 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
126 'FIELD_NAME' =>
'UF_DESCRIPTION',
127 'USER_TYPE_ID' =>
'string',
128 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_DESCR',
132 'SHOW_FILTER' =>
'N',
133 'SHOW_IN_LIST' =>
'Y',
134 'EDIT_IN_LIST' =>
'Y',
135 'IS_SEARCHABLE' =>
'Y',
138 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
139 'FIELD_NAME' =>
'UF_FULL_DESCRIPTION',
140 'USER_TYPE_ID' =>
'string',
141 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_FULL_DESCR',
145 'SHOW_FILTER' =>
'N',
146 'SHOW_IN_LIST' =>
'Y',
147 'EDIT_IN_LIST' =>
'Y',
148 'IS_SEARCHABLE' =>
'Y',
151 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
152 'FIELD_NAME' =>
'UF_SORT',
153 'USER_TYPE_ID' =>
'double',
154 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_SORT',
158 'SHOW_FILTER' =>
'N',
159 'SHOW_IN_LIST' =>
'Y',
160 'EDIT_IN_LIST' =>
'Y',
161 'IS_SEARCHABLE' =>
'N',
164 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
165 'FIELD_NAME' =>
'UF_EXTERNAL_CODE',
166 'USER_TYPE_ID' =>
'string',
167 'XML_ID' =>
'UF_BRAND_FOR_FACEBOOK_EXTERNAL_CODE',
171 'SHOW_FILTER' =>
'N',
172 'SHOW_IN_LIST' =>
'Y',
173 'EDIT_IN_LIST' =>
'Y',
174 'IS_SEARCHABLE' =>
'N',
177 'ENTITY_ID' =>
'HLBLOCK_' . $highLoadBlockId,
178 'FIELD_NAME' =>
'UF_XML_ID',
179 'USER_TYPE_ID' =>
'string',
180 'XML_ID' =>
'UF_XML_ID',
184 'SHOW_FILTER' =>
'N',
185 'SHOW_IN_LIST' =>
'Y',
186 'EDIT_IN_LIST' =>
'Y',
187 'IS_SEARCHABLE' =>
'N',
192 $languageResult = CLanguage::GetList();
193 while($language = $languageResult->Fetch())
195 $languageIds[] = $language[
'LID'];
198 $userTypeEntity =
new CUserTypeEntity;
199 foreach ($userFields as $userField)
201 $userTypeResult = CUserTypeEntity::GetList(
204 'ENTITY_ID' => $userField[
'ENTITY_ID'],
205 'FIELD_NAME' => $userField[
'FIELD_NAME'],
208 if ($userTypeResult->Fetch())
214 foreach($languageIds as $languageId)
217 $labelNames[$languageId] = $messages[$userField[
'FIELD_NAME']];
220 $userField[
'EDIT_FORM_LABEL'] = $labelNames;
221 $userField[
'LIST_COLUMN_LABEL'] = $labelNames;
222 $userField[
'LIST_FILTER_LABEL'] = $labelNames;
224 $userTypeEntity->Add($userField);
static loadLanguageFile($file, $language=null, $normalize=true)