• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Broker/IBlockElement.php
  • Класс: Bitrix\Crm\Service\Broker\IBlockElement
  • Вызов: IBlockElement::loadEntries
protected function loadEntries(array $ids): array
{
	if (!$this->isIblockIncluded())
	{
		return [];
	}

	Type\Collection::normalizeArrayValuesByInt($ids);
	if (empty($ids))
	{
		return [];
	}

	$result = [];
	$iblockElements = [];
	foreach (array_chunk($ids, 500) as $pageIds)
	{
		$iterator = Iblock\ElementTable::getList([
			'select' => [
				'ID',
				'IBLOCK_ID',
				'NAME',
			],
			'filter' => [
				'@ID' => $pageIds,
			],
		]);
		while ($row = $iterator->fetch())
		{
			$row['ID'] = (int)$row['ID'];
			$row['IBLOCK_ID'] = (int)$row['IBLOCK_ID'];
			$id = $row['ID'];
			$iblockId = $row['IBLOCK_ID'];
			if (!isset($iblockElements[$iblockId]))
			{
				$iblockElements[$iblockId] = [];
			}
			$iblockElements[$iblockId][] = $id;
			$result[$id] = $row;
		}
		unset($row, $iterator);
	}


	foreach (array_keys($iblockElements) as $iblockId)
	{
		if ($this->isCrmCatalog($iblockId))
		{
			$urlList = $this->getDetailUrls($iblockId, $iblockElements[$iblockId]);
			foreach ($urlList as $id => $url)
			{
				$result[$id]['DETAIL_PAGE_URL'] = $url;
			}
			unset($urlList);
		}
		else
		{
			foreach ($iblockElements[$iblockId] as $pageIds)
			{
				$iterator = \CIBlockElement::GetList(
					[],
					[
						'ID' => $pageIds,
						'IBLOCK_ID' => $iblockId,
						'CHECK_PERMISSIONS' => 'N',
					],
					false,
					false,
					[
						'ID',
						'IBLOCK_ID',
						'DETAIL_PAGE_URL',
					]
				);
				while ($row = $iterator->GetNext())
				{
					$id = (int)$row['ID'];
					$result[$id]['DETAIL_PAGE_URL'] = $row['DETAIL_PAGE_URL'];
				}
				unset($row, $iterator);
			}
		}
	}
	unset($iblockElements);

	return $result;
}