CIBlockElement::Upd ate(
 int ID,
 array arFields,
 bool bWorkFlow = false,
 bool bUpdateSearch = true

The method modifies parameters of element with ID. Before modifying an element, handlers of the event OnStartIBlockElementUpdate are called and which field values can be modified or an element modification rolled back by returning false. After element is modified, the event OnAfterIBlockElementUpdate itself is called. Non-static method.

When the fileproperty type is modified, you must generate an array.


Parameter DescriptionAvailable fr om version
ID Modified element ID.
arFields Array type: Array("field"=>"value", ...), containing values of iblock element fields and can contain the field "PROPERTY_VALUES" additionally, represented by an array with all element property values: Array("property code"=>"property value"). Where
"property code" - is the numeric or mnemonic property identifier,
"property value" - single value or an array of values for multiple-value properties.
Please note that the PROPERTY_VALUES array must contain a full set of properties and values; in case any currently existing property is missing from this array, all its values are removed from the element property set.
It applies to all property type, except when type is file. Files must be deleted via array with parameter "del"=>"Y".
When property type is list, pass to the PROPERTY_VALUES a value ID instead of the name.
Additionally, to save property values, see: CIBlockElement::SetPropertyValues(), CIBlockElement::[link=90663]SetPropertyValueCode().[/link]

Note 1: The values of ID and IBLOCK_ID fields cannot be modified.

Note 2:To avoid updating the TIMESTAMP_X field with the current time when updating an element, pass the following to arFields:
bWorkFlow Modifying in the workflow mode. When returns true and workflow module is installed, any modified parameters are recorded in the element's log. Optional parameter. Modifications in workflow mode are disabled by default.
Note: when in workflow mode, not all property values can be passed in PROPERTY_VALUES: only required parameters are permitted.
bUpdateSearch Index an element for search. This parameter can be disabled during a series of element modifications to increase performance. When all modifications are complete, manually re-index the search. Optional parameter. By default, an element is automatically re-indexed in the search after its modified. 3.2.1
bResizePicturesUse iblock settings to process images. The settings are not applied by default. When this parameter is true, the fields PREVIEW_PICTURE and DETAIL_PICTURE will use relies for generating and scaling in accordance with iblock settings.8.0.10
bCheckDiskQuotaEnables checking limits of disk space occupied by database and files (kernel setting). Optional parameter.11.0.14

Returned value

The method returns true on success and false when error occurs and the object's property LAST_ERROR will contain error description.

See Also


$el = new CIBlockElement;

$PROP = array();
$PROP[12] = "White"; // property with code 12 assigned with value "White"
$PROP[3] = 38; // property with code 3 assigned with value 38

$arLoadProductArray = Array(
"MODIFIED_BY" => $USER->GetID(), // element is modified by the current user
"IBLOCK_SECTION" => false, // element is located in the section root
"NAME" => "Element",
"ACTIVE" => "Y", // is active
"PREVIEW_TEXT" => "text for element list",
"DETAIL_TEXT" => "text for detail view",
"DETAIL_PICTURE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/image.gif")

$PRODUCT_ID = 2; // modify element with code (ID) 2
$res = $el->Update($PRODUCT_ID, $arLoadProductArray);

The parameter IBLOCK_ID cannot be modified.

Example for setting a new value for additional property:

For the type HTML/TEXT, when inserting HTML code and automatic connection of HTML editor:
$PROP[tables] = array("VALUE" => array("TYPE" =>"HTML","TEXT" => $matches[0])); 
For the type HTML/TEXT, when inserting plain text:
$PROP[tables] = array("VALUE" => array("TYPE" =>"TEXT","TEXT" => $matches[0])); 
© «Bitrix24», 2001-2023