U
U
urajo2022-03-10 11:12:24
1C-Bitrix
urajo, 2022-03-10 11:12:24

How to get infoblock element properties?

I output the infoblock and its elements like this. Elements have additional properties, how to get them in this code?

$arOrder = Array("SORT"=>"ASC");
  $arFilter = Array(
  "IBLOCK_SECTION_ID" => $arResult["ID"],
  "SORT_BY1" => $arParams["SORT_BY1"],
    "SORT_ORDER1" => $arParams["SORT_ORDER1"],
    "SORT_BY2" => $arParams["SORT_BY2"],
    "SORT_ORDER2" => $arParams["SORT_ORDER2"],
  'GLOBAL_ACTIVE'=>'Y',
  );
  $obElement = CIBlockElement::GetList($arOrder, $arFilter, false, false, Array());
  while($ar_fields = $obElement->GetNext())
  {
    var_dump($ar_fields['NAME']);
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Livach, 2022-03-10
@Mausglov

see the fifth parameter in CIBlockElement::GetList() in the documentation for examples.
remarks:

  1. $obElement is not an obElement, that is, not an "element of type 'object'". There is an instance of the CIBlockResult class, it is basically denoted as $res.
  2. you have some strange filter, sorting is stuffed into it for some reason. As far as I remember the internal structure of CIBlockElement::GetList(), all this is ignored as garbage. There is also $arOrder, use it.
  3. my IMHO: although the Hungarian notation is accepted in Bitrix, it has been dragging on since ancient times, it is used erroneously and therefore does not make sense.

A
Anton, 2022-03-10
@anton99zel

$arFilter = Array(
  "ID" => УКАЖИ, 
  "IBLOCK_ID"=>УКАЖИ, 
  "IBLOCK_SECTION_ID" => $arResult["ID"],
  );
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_CODE");
$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement()){ 
 $arFields = $ob->GetFields();  
print_r($arFields);
 $arProps = $ob->GetProperties();
print_r($arProps);
}

PROPERTY_CODE, for example PROPERTY_COLOR
https://dev.1c-bitrix.ru/api_help/iblock/classes/c... Redo
the sorting yourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question