ProductLoader::loadMap

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ProductLoader
  4. loadMap
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/documentgenerator/productloader.php
  • Класс: Bitrix\Crm\Integration\DocumentGenerator\ProductLoader
  • Вызов: ProductLoader::loadMap
protected function loadMap(): void
{
	if ($this->productIds !== null)
	{
		return;
	}
	$this->productIds = [];
	$this->offerIds = [];
	$this->offerToProductsMap = [];

	$allIds = [];

	foreach ($this->rows as $row)
	{
		$itemId = (int)$row['PRODUCT_ID'];
		if ($itemId > 0)
		{
			$allIds[$itemId] = (int)$row['ID'];
		}
	}

	$offersData = \CCatalogSku::getProductList(array_keys($allIds), $this->offerIblockId);
	if (is_array($offersData))
	{
		foreach ($offersData as $offerId => $offerData)
		{
			$this->offerIds[$offerId] = $allIds[$offerId];
			$productId = (int)$offerData['ID'];
			$this->productIds[$productId] = $allIds[$productId] ?? null;
			$this->offerToProductsMap[$offerId] = $productId;
		}
	}

	foreach ($allIds as $productId => $rowId)
	{
		if (!isset($this->offerIds[$productId]) && !isset($this->productIds[$productId]))
		{
			$this->productIds[$productId] = $rowId;
		}
	}
}

Добавить комментарий