Answer the question
In order to leave comments, you need to log in
Display the name of the element "binding to elements" Bitrix?
Good afternoon!
In init.php through the API I want to get the NAME of the element "binding to elements". I'm trying this way.
$res = CIBlockElement::GetProperty($IBLOCK_ID, $ELEMENT_ID, array("sort" => "asc"), Array("CODE"=>"TOVAR"));
while ($ob = $res->GetNext()) {
$TOVAR_NAME = $ob['VALUE'];
}
Answer the question
In order to leave comments, you need to log in
The name of the element is not stored in the property, only its ID is stored.
Therefore, you first get its ID as you did and make a second request CIBlockElement::GetByID or even better CIBlockElement::GetList, that is, you get the data of the element itself.
$res = CIBlockElement::GetProperty($IBLOCK_ID, $ELEMENT_ID, array("sort" => "asc"), Array("CODE"=>"TOVAR"));
while ($ob = $res->GetNext()) {
$id = $ob['VALUE'];
$element = CIBlockElement::GetList([], ['=ID' => $id], false, false, ['ID', 'NAME'])->Fetch();
}
$element = CIBlockElement::GetList(
[],
[
'IBLOCK_ID' => $IBLOCK_ID,
'=ID' => $ELEMENT_ID
],
false,
false,
['ID', 'PROPERTY_TOVAR.NAME']
)->Fetch();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question