...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmProductRestProxy
- Вызов: CCrmProductRestProxy::innerUpdate
protected function innerUpdate($ID, &$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::CheckUpdatePermission($ID)) { $errors[] = 'Access denied.'; return false; } $catalogID = CCrmCatalog::GetDefaultID(); if($catalogID <= 0) { $errors[] = 'Product catalog is not found.'; return false; } //EnsureDefaultCatalogScope will check if product exists in default catalog if(!CCrmProduct::EnsureDefaultCatalogScope($ID)) { $errors[] = 'Product is not found'; return false; } if (isset($fields['DESCRIPTION'])) { $descriptionType = ''; if (isset($fields['DESCRIPTION_TYPE'])) { $descriptionType = $fields['DESCRIPTION_TYPE']; } if ($descriptionType !== 'html' && $descriptionType !== 'text') { $res = CCrmProduct::GetList(array(), array('ID' => $ID), array('DESCRIPTION_TYPE')); if ($row = $res->Fetch()) { $descriptionType = $row['DESCRIPTION_TYPE']; } unset($res, $row); } if ($descriptionType !== 'html' && $descriptionType !== 'text') { $descriptionType = 'text'; } $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(!empty($propertyValues)) { $fields['PROPERTY_VALUES'] = $propertyValues; $rsProperties = CIBlockElement::GetProperty( $catalogID, $ID, 'sort', 'asc', array('ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N') ); while($property = $rsProperties->Fetch()) { if($property['PROPERTY_TYPE'] !== 'F' && !array_key_exists($property['ID'], $propertyValues)) { if(!array_key_exists($property['ID'], $fields['PROPERTY_VALUES'])) $fields['PROPERTY_VALUES'][$property['ID']] = array(); $fields['PROPERTY_VALUES'][$property['ID']][$property['PROPERTY_VALUE_ID']] = array( 'VALUE' => $property['VALUE'], 'DESCRIPTION' => $property['DESCRIPTION'] ); } } } $result = CCrmProduct::Update($ID, $fields); if($result !== true) { $errors[] = CCrmProduct::GetLastError(); } return $result; }