S
S
sagaton2021-11-09 16:39:13
1C-Bitrix
sagaton, 2021-11-09 16:39:13

How in SetPropertyValuesEx to access not the value id for a property of the List type, but XML_ID?

How in SetPropertyValuesEx to access not the value id for a property of the List type, but XML_ID?
For example
$ELEMENT_ID = 33; // element code
$PROPERTY_CODE = "Seasons"; // property code
$PROPERTY_VALUE = "184"; // property value
184 it is not static but periodically interposed. Therefore, you need to refer to xml_id. But in SetPropertyValuesEx, I did not find an example of how this can be done.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tgarl, 2021-11-09
@tgarl

Because there is no such possibility, the documentation says about it.
To do this, you get all the values ​​​​of the list separately, look for your xml_id there, find out its id and substitute it,
i.e.

$db_enum_list = CIBlockProperty::GetPropertyEnum("BREND", Array('sort' => 'asc'), Array("IBLOCK_ID"=>$arParams["IBLOCK_ID"]));
while($ar_enum_list = $db_enum_list->GetNext())
{$arrProp[]=$ar_enum_list;}//получили значения списка, если требуется именно по xml_id, то сразу формируйте с ключами нужными
//$arrProp[$ar_enum_list['XML_ID']]=$ar_enum_list; - лень принтовать проверьте у себя сами правильность написания
//ну а далее 
// пусть будет id = 184, xml_id=leto, value=лето
$PROPERTY_VALUE = $arrProp['leto']['id'];

more or less like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question