• Модуль: market
  • Путь к файлу: ~/bitrix/modules/market/lib/ListTemplates/Favorites.php
  • Класс: BitrixMarketListTemplatesFavorites
  • Вызов: Favorites::setResult
public function setResult(bool $isAjax = false)
{
	$title = Loc::getMessage('MARKET_FAVORITES_PAGE_TITLE');

	$this->result['TITLE'] = $title;

	global $APPLICATION;
	$APPLICATION->SetTitle($title);

	$this->result['CURRENT_APPS_CNT'] = count(AppFavoritesTable::getUserFavorites());

	$nav = new PageNavigation('market-favorites-nav');
	$nav->setPageSize(20)
		->setCurrentPage($this->page)
		->setRecordCount($this->result['CURRENT_APPS_CNT']);

	$this->result['CUR_PAGE'] = $nav->getCurrentPage();
	$this->result['PAGES'] = $nav->getPageCount();

	$this->result['ALL_CODES'] = AppFavoritesTable::getUserFavoritesForList($nav->getOffset(), $nav->getLimit());
	if (empty($this->result['ALL_CODES'])) {
		$this->result['APPS'] = [];
		return;
	}

	$batch = [
		Transport::METHOD_FILTER_APP => [
			Transport::METHOD_FILTER_APP,
			[
				'app_codes' => $this->result['ALL_CODES'],
				'_market_' => 'Y',
			],
		],
		Transport::METHOD_TOTAL_APPS => [
			Transport::METHOD_TOTAL_APPS,
		],
	];
	if (!$isAjax && empty(Categories::get())) {
		$batch[Transport::METHOD_GET_CATEGORIES_V2] = [Transport::METHOD_GET_CATEGORIES_V2];
	}

	$response = Transport::instance()->batch($batch);
	if (
		isset($response[Transport::METHOD_FILTER_APP]) &&
		isset($response[Transport::METHOD_FILTER_APP]['ITEMS']) &&
		is_array($response[Transport::METHOD_FILTER_APP]['ITEMS'])
	) {
		$this->prepareApps($response[Transport::METHOD_FILTER_APP]['ITEMS']);
	}

	if (!empty($response[Transport::METHOD_GET_CATEGORIES_V2])) {
		Categories::saveCache($response[Transport::METHOD_GET_CATEGORIES_V2]);
		$this->result['CATEGORIES'] = Categories::get();
	}

	$this->result['TOTAL_APPS'] = NumberApps::get($response[Transport::METHOD_TOTAL_APPS]);
}