...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmProductRestProxy
- Вызов: CCrmProductRestProxy::innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null) { if(!is_array($fields)) { throw new RestException("The parameter 'fields' must be array."); } if(!CModule::IncludeModule('iblock')) { throw new RestException('Could not load iblock module.'); } if(!CCrmProduct::CheckCreatePermission()) { $errors[] = 'Access denied.'; return false; } $catalogID = intval(CCrmCatalog::EnsureDefaultExists()); if($catalogID <= 0) { $errors[] = 'Default catalog is not exists.'; return false; } if (isset($fields['DESCRIPTION'])) { $descriptionType = (isset($fields['DESCRIPTION_TYPE']) && $fields['DESCRIPTION_TYPE'] === 'html') ? 'html' : 'text'; $fields['DESCRIPTION_TYPE'] = $descriptionType; $description = (isset($fields['DESCRIPTION']) && is_string($fields['DESCRIPTION'])) ? trim($fields['DESCRIPTION']) : '' ; $isNeedSanitize = ( $descriptionType === 'html' && $description !== '' && mb_strpos($description, '<') !== false ); if ($isNeedSanitize) { $description = self::sanitizeHtml($description); } $fields['DESCRIPTION'] = $description; unset($descriptionType, $description, $isNeedSanitize); } // Product properties $this->initializePropertiesInfo($catalogID); $propertyValues = array(); foreach ($this->properties as $propId => $property) { if (isset($fields[$propId])) $propertyValues[$property['ID']] = $fields[$propId]; unset($fields[$propId]); } if(count($propertyValues) > 0) $fields['PROPERTY_VALUES'] = $propertyValues; $result = CCrmProduct::Add($fields); if(!is_int($result)) { $errors[] = CCrmProduct::GetLastError(); } return $result; }