S
S
SpectreZ2021-02-11 09:51:01
1C-Bitrix
SpectreZ, 2021-02-11 09:51:01

How to get property values ​​with the same character code from several infoblocks at the same time?

There are several infoblocks of the same type, all of them have properties with the symbolic code PRICE_M2, the data type is a number. I get elements from these infoblocks as follows:

$filter = [
  'IBLOCK_TYPE' => $this->arParams['IBLOCK_TYPE'],
  'IBLOCK_ID' => $iblocksIds //массив идентификаторов инфоблоков
];


$resultRaw = CIBlockElement::getList(
  ['sort' => 'asc'],
  $filter,
  false, false,
  [
    'ID', 'IBLOCK_ID', 'NAME',
    'DETAIL_PICTURE', 'DETAIL_PAGE_URL',
    'PROPERTY_PRICE_M2'
  ]
);


An empty array is returned. When I remove "PROPERTY_PRICE_M2" from the array of requested values, all required elements are returned.

When I write "PROPERTY_416" instead of "PROPERTY_PRICE_M2" (property identifier in one of the infoblocks), then all the necessary elements are also returned, but this property is filled only for the elements of one infoblock, the rest are null.

Tell me, what could be the problem of obtaining data by character code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kudis, 2021-02-11
@kudis

In the filter, you can check if the infoblock element has a value, if you, of course, need only elements with a filled property.
Get by CODE I suggest the following construction

while ($obElement = $resultRaw->GetNextElement()) {
    $arProperties = $obElement->GetProperties(false, ['CODE' => 'PRICE_M2']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question