• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/v2/Price/PriceCollection.php
  • Класс: BitrixCatalogv2PricePriceCollection
  • Вызов: PriceCollection::prepareValues
private function prepareValues(array $values): array
{
	// ToDo check required properties + QUANTITY_FROM etc
	$prepared = [];

	foreach ($values as $id => $fields)
	{
		if (!is_array($fields))
		{
			if (is_numeric($fields) && is_finite($fields))
			{
				$fields = ['PRICE' => $fields];
			}
			else
			{
				continue;
			}
		}

		$fields = array_intersect_key($fields, ['PRICE' => true, 'CURRENCY' => true]);
		if (!empty($fields))
		{
			if (isset($fields['PRICE']))
			{
				if (is_numeric($fields['PRICE']) && is_finite($fields['PRICE']))
				{
					$fields['PRICE'] = (float)$fields['PRICE'];
				}
				else
				{
					$fields['PRICE'] = null;
				}
			}

			if (isset($fields['CURRENCY']) && !is_string($fields['CURRENCY']))
			{
				unset($fields['CURRENCY']);
			}
		}

		if (!empty($fields))
		{
			if (is_numeric($id))
			{
				$id = (int)$id;
				$prepared[$id] = $fields;
			}
			elseif ($id === 'BASE')
			{
				$basePrice = CCatalogGroup::GetBaseGroup();

				if (!empty($basePrice['ID']))
				{
					$id = (int)$basePrice['ID'];
					$prepared[$id] = $fields;
				}
			}
		}
	}

	return $prepared;
}