• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/grid/row/assembler/morephotoassembler.php
  • Класс: BitrixCatalogGridRowAssemblerMorePhotoAssembler
  • Вызов: MorePhotoAssembler::loadEntities
private function loadEntities(array $rowList): void
{
	$this->entities = [];

	$productToOfferId = $this->getSettings()->getSelectedProductOfferIds();
	$offerToProductId = array_flip($productToOfferId);

	$ids = [];
	foreach ($rowList as $row)
	{
		$id = (int)($row['data']['ID'] ?? 0);
		if ($id === 0)
		{
			continue;
		}

		$type = $row['data']['ROW_TYPE'] ?? null;
		if ($type !== RowType::ELEMENT)
		{
			continue;
		}

		// replace `product id` to `offer id` to display correct offer image.
		if (isset($productToOfferId[$id]))
		{
			$id = $productToOfferId[$id];
		}

		$ids[] = $id;
	}

	if (empty($ids))
	{
		return;
	}

	$repository = ServiceContainer::getProductRepository($this->getIblockId());
	if (isset($repository))
	{
		$items = $repository->getEntitiesBy([
			'filter' => [
				'ID' => $ids,
			],
		]);
		foreach ($items as $item)
		{
			/**
			 * @var BaseProduct $item
			 */

			$this->entities[$item->getId()] = $item;
		}
	}

	$offersIblockId = $this->getOffersIblockId();
	$repository =
		isset($offersIblockId)
			? ServiceContainer::getSkuRepository($offersIblockId)
			: null
	;
	if (isset($repository))
	{
		$items = $repository->getEntitiesBy([
			'filter' => [
				'ID' => $ids,
			],
		]);
		foreach ($items as $item)
		{
			/**
			 * @var BaseSku $item
			 */

			$productId = $offerToProductId[$item->getId()];
			$this->entities[$productId] = $item;
		}
	}
}