<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();

if (empty($arResult['ITEMS'])) {
    return;
}

\Bitrix\Main\Loader::includeModule('iblock');

// Собираем ID всех элементов
$ids = [];
foreach ($arResult['ITEMS'] as $item) {
    if (!empty($item['ID'])) {
        $ids[] = (int)$item['ID'];
    }
}
$ids = array_values(array_unique($ids));
if (empty($ids)) {
    return;
}

// Догружаем нужные поля «правильным» способом
$arSelect = [
    'ID',
    'NAME',
    'PREVIEW_TEXT',
    'PREVIEW_PICTURE',
    'DETAIL_PAGE_URL',
    'DATE_ACTIVE_FROM',
    'ACTIVE_FROM',
];

$res = CIBlockElement::GetList(
    [],
    ['ID' => $ids],
    false,
    false,
    $arSelect
);

$byId = [];
while ($el = $res->GetNext()) {
    $byId[(int)$el['ID']] = $el;
}

// Подменяем структуру в $arResult['ITEMS']
foreach ($arResult['ITEMS'] as &$item) {
    $id = (int)$item['ID'];
    if (isset($byId[$id])) {
        $item = array_merge($item, $byId[$id]);
    }
}
unset($item);
Страницы: Пред. 1 ... 588 589 590 591 592 ... 603 След.