26 public static function getSkuProperties(
int $iblockId,
int $skuId, array $filter = []): array
29 $product = Catalog\ProductTable::getRow([
31 'SKU_NAME' =>
'IBLOCK_ELEMENT.NAME',
32 'SKU_DESCRIPTION' =>
'IBLOCK_ELEMENT.DETAIL_TEXT',
34 'PURCHASING_CURRENCY',
40 'filter' => [
'=ID' => $skuId],
43 $properties[
'SKU_ID'] = $skuId;
45 if ($product !==
null)
47 $properties[
'PURCHASING_PRICE'] = round((
float)$product[
'PURCHASING_PRICE'], self::PRICE_PRECISION);
48 if (Loader::includeModule(
'crm'))
50 $properties[
'PURCHASING_PRICE_FORMATTED'] = \CCrmCurrency::MoneyToString(
51 $product[
'PURCHASING_PRICE'],
52 $product[
'PURCHASING_CURRENCY']
55 elseif (Loader::includeModule(
'currency'))
57 $properties[
'PURCHASING_PRICE_FORMATTED'] = \CCurrencyLang::CurrencyFormat(
58 $product[
'PURCHASING_PRICE'],
59 $product[
'PURCHASING_CURRENCY']
64 $properties[
'PURCHASING_PRICE_FORMATTED'] = htmlspecialcharsbx(
65 $product[
'PURCHASING_PRICE'] .
' ' . $product[
'PURCHASING_CURRENCY']
68 $properties[
'LENGTH'] = $product[
'LENGTH'];
69 $properties[
'WEIGHT'] = $product[
'WEIGHT'];
70 $properties[
'WIDTH'] = $product[
'WIDTH'];
71 $properties[
'HEIGHT'] = $product[
'HEIGHT'];
72 $properties[
'SKU_NAME'] = htmlspecialcharsbx($product[
'SKU_NAME']);
73 $properties[
'SKU_DESCRIPTION'] = (new \CBXSanitizer())->SanitizeHtml($product[
'SKU_DESCRIPTION']);
77 $properties[
'PURCHASING_PRICE'] = 0;
78 $properties[
'PURCHASING_PRICE_FORMATTED'] =
'';
79 $properties[
'LENGTH'] =
null;
80 $properties[
'WEIGHT'] =
null;
81 $properties[
'WIDTH'] =
null;
82 $properties[
'HEIGHT'] =
null;
83 $properties[
'SKU_NAME'] =
'';
84 $properties[
'SKU_DESCRIPTION'] =
'';
103 $filter[
'ACTIVE'] =
'Y';
105 $props = \CIBlockElement::GetProperty($iblockId, $productId,
'id',
'asc', $filter);
106 while ($prop = $props->GetNext())
108 if (empty($prop[
'VALUE'])
109 && !($prop[
'PROPERTY_TYPE'] ===
'L' && $prop[
'LIST_TYPE'] ===
'C')
115 $code =
'PROPERTY_' . $prop[
'ID'];
117 switch ($prop[
'PROPERTY_TYPE'])
119 case PropertyTable::TYPE_STRING:
120 case PropertyTable::TYPE_NUMBER:
121 if ($prop[
'USER_TYPE'] === PropertyTable::USER_TYPE_DIRECTORY
122 && isset($prop[
'USER_TYPE_SETTINGS'][
'TABLE_NAME'])
123 && Loader::includeModule(
'highloadblock')
126 $value = self::getDirectoryValue($prop);
128 else if ($prop[
'USER_TYPE'] === PropertyTable::USER_TYPE_HTML)
130 $value = (new \CBXSanitizer())->SanitizeHtml($prop[
'~VALUE'][
'TEXT']);
134 $value = $prop[
'VALUE'];
137 if (!isset($result[$code]))
139 $result[$code] = $value;
143 $result[$code] .=
', ' . $value;
147 case PropertyTable::TYPE_LIST:
148 if ($prop[
'LIST_TYPE'] === PropertyTable::CHECKBOX)
150 switch ($prop[
'VALUE_ENUM'])
153 $value =
Loc::getMessage(
'CRM_ENTITY_PRODUCT_LIST_COLUMN_CHECKBOX_YES');
157 $value =
Loc::getMessage(
'CRM_ENTITY_PRODUCT_LIST_COLUMN_CHECKBOX_NO');
160 $value = htmlspecialcharsbx($prop[
'VALUE_ENUM']);
162 $result[$code] = $value;
167 if ($prop[
'MULTIPLE'] !==
'Y')
169 $result[$code] = $prop[
'VALUE_ENUM'];
174 if (!isset($result[$code]))
176 $result[$code] = $prop[
'VALUE_ENUM'];
180 $result[$code] .=
', ' . $prop[
'VALUE_ENUM'];
184 case PropertyTable::TYPE_FILE:
185 Loader::includeModule(
'fileman');
186 $listImageSize = (int)Option::get(
'iblock',
'list_image_size');
192 'W' => $listImageSize,
193 'H' => $listImageSize,
195 $result[$code] ??=
'';
196 $result[$code] .= \CFileInput::Show(
197 'NO_FIELDS[' . $productId .
']',
204 'IMAGE_POPUP' =>
'N',
205 'MAX_SIZE' => $maxImageSize,
206 'MIN_SIZE' => $minImageSize,
211 'file_dialog' =>
false,
214 'description' =>
false,
220 $result[$code] = htmlspecialcharsbx($prop[
'VALUE']);
271 $iterator = PropertyTable::getList([
279 '=IBLOCK_ID' => self::getIblockIds(),
283 '==USER_TYPE' =>
null,
285 '@USER_TYPE' => self::getAllowedPropertyUserTypes(),
287 '!@PROPERTY_TYPE' => self::getRestrictedPropertyTypes(),
288 '!@CODE' => self::getRestrictedProperties(),
291 'IBLOCK_ID' =>
'ASC',
297 while ($prop = $iterator->fetch())
299 $result[] =
'PROPERTY_' . $prop[
'ID'];
313 return array_merge($result, $skuFields);
354 PropertyTable::USER_TYPE_DATE,
355 PropertyTable::USER_TYPE_DATETIME,
356 PropertyTable::USER_TYPE_DIRECTORY,
357 PropertyTable::USER_TYPE_HTML,