A
A
alexander_chn2019-10-12 18:36:53
API
alexander_chn, 2019-10-12 18:36:53

How to display a multiple property in Bitrix via API?

Hello! Bitrix has a multiple property of the list type with the following parameters:
5da1f2f316ce1877961142.png
Here is the code by which I display this property:

<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");

$iblock_id  = 2;
$section_id = 34;

$arSelect = Array(
  "ID", 
  "NAME",
  "PROPERTY_ACTION");

$arFilter = Array( "IBLOCK_ID"=>$iblock_id, "SECTION_ID"=>$section_id, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y" );
$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, false, $arSelect);

while($ob = $res->GetNextElement()) :
  $arFields = $ob->GetFields();
  echo $arFields['PROPERTY_ACTION_VALUE'] . '<hr>';
endwhile;

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

The output is this:
5da1f312c6b23489358615.png
There are 7 products in this section, and only one product with a value filled in. This product has all the values.
It is displayed strangely, that is, with each pass of the loop, it displays one value of this multiple property.
How to get it out right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex-1917, 2019-10-12
@alexander_chn

this code will be inside your cycle, this is Bitrix, alas and ah

$VALUES = array();
$res = CIBlockElement::GetProperty($IBLOCK_ID, $ELEMENT_ID, Array("sort"=>"asc"), array("CODE" => "UF_NOTE_USER"));
    while ($ob = $res->GetNext())
    {
        $VALUES[] = $ob['VALUE'];
    }
}

Or another variant - if you include the plural in arSelect, then you will have such a nuance, it is described in the docks:
I do this - I include the multiple in arselect, but then in php I cut off the repetitions, the values ​​​​of the multiple fields that are the first by sorting will remain in the array.
This is Bitrix, baby, this is Bitrix.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question