A
A
Alexander2020-05-11 16:38:21
1C-Bitrix
Alexander, 2020-05-11 16:38:21

Bitrix API, how can I get the value of infoblock element properties in D7?

Tell me how, using the D7 core API, you can get the value of the properties of an infoblock element and make a selection of infoblock elements by properties?

There is an infoblock News, its elements have the PROPERTY_SPORT_TYPE property, this property is a link to the infoblock element Sports. For example, there are 5 football news and I have to get them.

Using the old API, I get a list of news for a specific sport using a filter like this:

$arFilter = array("IBLOCK_ID"=>$iblock_id, "ACTIVE_FROM","=PROPERTY_SPORT_TYPE"=>$sport_type_id);

How to organize sorting in D7 by properties?

In the old kernel, I use the getProperty method, this is how the whole code looks like:

$arSelect = array("ID", "NAME", "DETAIL_PAGE_URL", "ACTIVE_FROM", "CODE", "PROPERTY_*");
$arFilter = array("IBLOCK_ID"=>$iblock_id, "ACTIVE_FROM","=PROPERTY_SPORT_TYPE"=>$sport_type_id);
$arItems = [];
$res = CIBlockElement::GetList(array(), $arFilter, false, array("nPageSize"=>500), $arSelect);
while($arItem = $res->fetch()){
    $dbProperty = CIBlockElement::getProperty($arItem['IBLOCK_ID'], $arItem['ID'], array("sort", "asc"),array());
      while ($arProperty = $dbProperty->GetNext()) {
        if($arProperty['CODE'] == 'SPORT_TYPE'){
          $arItem['SPORT_TYPE'][] =  $arProperty['VALUE'];   
        }    
    }
}


Is there an analogue of the CIBlockElement::getProperty method in the D7 core?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Emelyanov, 2020-05-12
@babarun

https://dev.1c-bitrix.ru/learning/course/?COURSE_I...

A
Alexander Solovey, 2021-02-19
@naghtigall

https://qna.habr.com/q/828871 - it was a D7 bug, they fixed it in kernel 20.200

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question