• Модуль: salescenter
  • Путь к файлу: ~/bitrix/modules/salescenter/lib/integration/restmanager.php
  • Класс: BitrixSalesCenterIntegrationRestManager
  • Вызов: RestManager::getMarketplaceAppCodeList
public function getMarketplaceAppCodeList(string $category): array
{
	$cacheId = "salescenter_category_{$category}_codes";
	$cachePath = "/salescenter/saleshub/codes/{$category}/";
	$cache = MainApplication::getInstance()->getCache();

	$appCodeList = [];
	if ($cache->initCache(self::DEFAULT_CACHE_TTL, $cacheId, $cachePath))
	{
		$appCodeList = $cache->getVars();
	}
	else
	{
		$page = 1;
		do
		{
			$categoryItems = RestMarketplaceClient::getCategory($category, $page, 100);
			if (!is_array($categoryItems)
				|| isset($categoryItems['ERROR'])
				|| empty($categoryItems['ITEMS'])
			)
			{
				break;
			}

			foreach ($categoryItems['ITEMS'] as $item)
			{
				$appCodeList[] = $item['CODE'];
			}
			$page++;
		}
		while((int)$categoryItems['PAGES'] !== (int)$categoryItems['CUR_PAGE']);

		if ($appCodeList)
		{
			$cache->startDataCache();
			$cache->endDataCache($appCodeList);
		}
	}

	return $appCodeList;
}