• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/documentgenerator/productloader.php
  • Класс: Bitrix\Crm\Integration\DocumentGenerator\ProductLoader
  • Вызов: ProductLoader::getPropertyElementValue
protected function getPropertyElementValue(int $propertyValue)
{
	if ($this->linkedElements === null)
	{
		$this->linkedElements = [];
		$elementProperties = [];
		$properties = array_merge($this->productProperties, $this->offerProperties);
		foreach ($properties as $property)
		{
			if ($property['PROPERTY_TYPE'] === 'E')
			{
				$propertyId = (int)$property['ID'];
				$elementProperties[$propertyId] = $property;
			}
		}

		foreach ($elementProperties as $property)
		{
			foreach ($this->getProductIds() as $productId)
			{
				$value = $this->getRawPropertyValue($property, $productId);
				if (
					isset($property['MULTIPLE'])
					&& $property['MULTIPLE'] === 'Y'
					&& is_array($value)
				)
				{
					foreach ($value as $id)
					{
						$this->linkedElements[$id] = [];
					}
				}
				elseif ($value > 0)
				{
					$this->linkedElements[$value] = [];
				}
			}
		}

		$notFoundElements = [];
		foreach ($this->linkedElements as $itemId => $data)
		{
			if (isset($this->iblockValues[$itemId]))
			{
				$this->linkedElements[$itemId] = $this->iblockValues[$itemId]['NAME'];
			}
			else
			{
				$notFoundElements[] = $itemId;
			}
		}

		if (!empty($notFoundElements))
		{
			$iterator = $this->elementTableClass::getList([
				'select' => ['ID', 'NAME'],
				'filter' => [
					'@ID' => $notFoundElements,
				],
			]);
			while($data = $iterator->fetch())
			{
				$this->linkedElements[(int)$data['ID']] = $data['NAME'];
			}
		}
	}

	return $this->linkedElements[$propertyValue] ?? null;
}