string PROPERTY_CODE = false

This method saves values of all iblock element properties. Static method.

Attention! You can delete and update several file property values only within a single call, not via several, due to property value IDs are being changed simultaneously. For example:

See Also

Call parameters

ELEMENT_ID Element ID with property values to be set.
IBLOCK_ID Information block ID.
PROPERTY_VALUES Array with property values, matching property codes and values.
When PROPERTY_CODE is set, it must contain a single or array with all property values (multiple) for specified element.
When PROPERTY_CODE is false, the PROPERTY_VALUES must be an Array("property code1"=>"property value1", ....), where "property code" - numerical or symbolic property code, "property values" - single or array of all property values (multiple). And the array PROPERTY_VALUES must contain a full set of property values for this element, i. e. if one of properties will be missing from it - all property values for this element will be deleted.
This is the case for all property types, except for file. Files must be deleted via array with the parameter "del"=>"Y".
When the file property type is multiple, the file will be deleted in case if the 'del' parameter is present, independently from its value.

  • When updating, you need to set all element properties, otherwise all unspecified properties will be reset.
  • When passing the array "property"=>"value", you must indicate list element external code as "list" property type.

  • List property type must pass the property value ID and not the value itself.
PROPERTY_CODE Update property code. When this parameter is different from false, updates only the property with this code. Optional parameter, set as false by default.


Example 1:

$ELEMENT_ID = 18; // element code
$PROPERTY_CODE = "PROP1"; // property code
$PROPERTY_VALUE = "Blue"; // property value

// Set new value for this property of this element
$dbr = CIBlockElement::GetList(array(), array("=ID"=>$ELEMENT_ID), false, false, array("ID", "IBLOCK_ID"));
if ($dbr_arr = $dbr->Fetch())
$IBLOCK_ID = $dbr_arr["IBLOCK_ID"];

Example 2 (method call code for the "String" property):

CIBlockElement::SetPropertyValueCode("$ELEMENT_ID", "code", $value);

Example 3 (method call for "HTML/text" property):

CIBlockElement::SetPropertyValueCode("$ELEMENT_ID", "code", array("VALUE"=>array("TEXT"=>$value, "TYPE"=>"html")));

Example 4 (adding a description to value):

CIBlockElement::SetPropertyValues ( $PRODUCT_ID, $IBLOCK_ID, array("VALUE"=>$prop_value,"DESCRIPTION"=>$prop_description), $property_name ); 

Example 5 (deleting "File" property):

CIBlockElement::SetPropertyValuesEx(ELEMENT_ID, IBLOCK_ID, array(PROPERTY_ID => Array ("VALUE" => array("del" => "Y")))); 

Example 6:

When a complete product details must be updated, including multiple type values (jointly with description), you can do it using a single Update call. You need to add the description (DESCRIPTION) to values (VALUE) of multiple type properties, write a numerical or symbolic property code (of multiple type) to PROPERTY_VALUES and assign array with value type as follows:

$arrFields = Array( 
   'PROPERTY_ID_OR_CODE' => Array( 
         "VALUE" => 'value1', 
         "DESCRIPTION" => 'desc for value1' 
         "VALUE" => 'value2', 
         "DESCRIPTION" => 'desc for value2'  
© «Bitrix24», 2001-2022