• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/sectionslist.php
  • Класс: BitrixSaleTradingPlatformVkSectionsList
  • Вызов: SectionsList::getSections
public function getSections($tree = false, $onlyMapped = true)
{
//		We can save data in cache.Cache must be reload only if sections settings will be changed.
	$cacheManager = Application::getInstance()->getManagedCache();
	$sections = array();

	if ($cacheManager->read(self::CACHE_TTL, $this->createCacheIdSections($onlyMapped)))
	{
		$sections = $cacheManager->get($this->createCacheIdSections($onlyMapped));
	}
	else
	{
//			get IBLOCK IDS only for mapped sections or for all catalogs
		$iblockIds = $this->getIblockIds($onlyMapped);
		$filter = array("IBLOCK_ID" => $iblockIds, "ELEMENT_SUBSECTIONS" => "N");

//			calculate all products or just active
		$vk = Vk::getInstance();
		$vkSettings = $vk->getSettings($this->exportId);
		if (isset($vkSettings["EXPORT_SETTINGS"]["ONLY_AVAILABLE_FLAG"]) && !$vkSettings["EXPORT_SETTINGS"]["ONLY_AVAILABLE_FLAG"])
		{
			$filter["CNT_ACTIVE"] = "N";
		}
		else
		{
			$filter["CNT_ACTIVE"] = "Y";
		}

//			get ALL sections for ALL catalog iblocks
		$resSections = CIBlockSection::GetList(
			array("LEFT_MARGIN" => "asc"),
			$filter,
			true,
			array(
				"IBLOCK_ID", "IBLOCK_SECTION_ID", "ID", "DEPTH_LEVEL", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN",
				"ELEMENT_CNT",
			)
		);

		while ($currSection = $resSections->Fetch())
		{
//				output format - list or tree separated on iblocks
			$sections[$currSection["IBLOCK_ID"]][$currSection["ID"]] = $currSection;
		}

		$cacheManager->set($this->createCacheIdSections($onlyMapped), $sections);
	}

//		if not a tree - formatted to list
	if (!$tree)
	{
		$sectionsList = [];
		foreach ($sections as $iblock)
		{
			$sectionsList += $iblock;
		}

		$sections = $sectionsList;
	}

	return $sections;
}