• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/basketitemcollection.php
  • Класс: BitrixSaleBasketItemCollection
  • Вызов: BasketItemCollection::getContext
public function getContext()
{
	global $USER;
	$context = array();

	/** @var BasketItem $basketItem */
	$basketItem = $this->rewind();
	if ($basketItem)
	{
		$siteId = $basketItem->getField('LID');
		$fuserId = $basketItem->getFUserId();

		$userId = Fuser::getUserIdById($fuserId);

		if (empty($context['SITE_ID']))
		{
			$context['SITE_ID'] = $siteId;
		}

		if (empty($context['USER_ID']) && $userId > 0)
		{
			$context['USER_ID'] = $userId;
		}
	}

	if (empty($context['SITE_ID']))
	{
		$context['SITE_ID'] = SITE_ID;
	}

	if (empty($context['USER_ID']))
	{
		$context['USER_ID'] = isset($USER) && $USER instanceof CUser ? (int)$USER->GetID() : 0;
	}

	if (Loader::includeModule('currency'))
	{
		if (!empty($context['SITE_ID']))
		{
			$currency = InternalsSiteCurrencyTable::getSiteCurrency($context['SITE_ID']);
		}

		if (empty($currency))
		{
			$currency = CurrencyCurrencyManager::getBaseCurrency();
		}

		if (!empty($currency) && CurrencyCurrencyManager::checkCurrencyID($currency))
		{
			$context['CURRENCY'] = $currency;
		}
	}

	return $context;
}