• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/discount/discountmanager.php
  • Класс: BitrixCatalogDiscountDiscountManager
  • Вызов: DiscountManager::prepareEntity
static function prepareEntity($entityList)
{
	$result = [
		'iblockFields' => [],
		'sections' => false,
		'iblockProperties' => [],
		'iblockPropertiesMap' => [],
		'catalogFields' => [],
		'priceFields' => []
	];

	if (!is_array($entityList))
		return false;

	if (empty($entityList['catalog']))
		return $result;

	if (!empty($entityList['catalog']))
	{
		if (!empty($entityList['catalog']['ELEMENT']) && is_array($entityList['catalog']['ELEMENT']))
		{
			foreach ($entityList['catalog']['ELEMENT'] as $entity)
			{
				if ($entity['FIELD_ENTITY'] == 'SECTION_ID')
				{
					$result['sections'] = true;
					continue;
				}
				$result['iblockFields'][$entity['FIELD_TABLE']] = $entity['FIELD_ENTITY'];
			}
			unset($entity);
		}
		if (!empty($entityList['catalog']['ELEMENT_PROPERTY']) && is_array($entityList['catalog']['ELEMENT_PROPERTY']))
		{
			foreach ($entityList['catalog']['ELEMENT_PROPERTY'] as $entity)
			{
				$propertyData = explode(':', $entity['FIELD_TABLE']);
				if (!is_array($propertyData) || count($propertyData) != 2)
					continue;
				$iblock = (int)$propertyData[0];
				$property = (int)$propertyData[1];
				unset($propertyData);
				if (!isset($result['iblockProperties'][$iblock]))
					$result['iblockProperties'][$iblock] = [];
				$result['iblockProperties'][$iblock][] = $property;
				if (!isset($result['iblockPropertiesMap'][$iblock]))
					$result['iblockPropertiesMap'][$iblock] = [];
				$result['iblockPropertiesMap'][$iblock][$property] = $entity['FIELD_ENTITY'];
			}
			unset($iblock, $property, $entity);
		}

		if (!empty($entityList['catalog']['PRODUCT']) && is_array($entityList['catalog']['PRODUCT']))
		{
			foreach ($entityList['catalog']['PRODUCT'] as $entity)
				$result['catalogFields'][$entity['FIELD_TABLE']] = $entity['FIELD_ENTITY'];
			unset($entity);
		}

		if (!empty($entityList['catalog']['PRICE']) && is_array($entityList['catalog']['PRICE']))
		{
			foreach ($entityList['catalog']['PRICE'] as $entity)
				$result['priceFields'][$entity['FIELD_TABLE']] = $entity['FIELD_ENTITY'];
			unset($entity);
		}
	}

	return $result;
}