Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getBrandTreeBySectionID($currentSectionId = "0")
- {
- $arBrandTree = ['BRAND' => [], 'GAMMA' => [], 'LINE' => [], 'TYPE' => ''];
- if (empty($currentSectionId))
- {
- return $arBrandTree;
- }
- $brandsTreeDictionary = new Dictionary();
- $cacheId = 'brandsTreeDictionary_' . self::CATALOG_IBLOCK_ID;
- $cacheDir = 'tagged_brands_tree';
- $cache = Cache::createInstance();
- if ($cache->initCache(14400, $cacheId, $cacheDir))
- {
- $brandsTreeDictionary->set($cache->getVars());
- }
- elseif ($cache->startDataCache())
- {
- $rCatalogSections = CIBlockSection::GetList([
- 'IBLOCK_ID' => self::CATALOG_IBLOCK_ID
- ], [
- 'ID',
- 'NAME',
- 'CODE',
- 'XML_ID',
- 'ACTIVE',
- 'SECTION_PAGE_URL',
- 'IBLOCK_SECTION_ID',
- 'DEPTH_LEVEL'
- ]);
- global $CACHE_MANAGER;
- $CACHE_MANAGER->StartTagCache($cacheDir);
- while ($arSection = $rCatalogSections->GetNext())
- {
- $CACHE_MANAGER->RegisterTag("iblock_id_".$arSection["ID"]."_".$arSection["IBLOCK_SECTION_ID"]);
- $arSection['SECTION_PAGE_URL'] = str_replace('/catalog/', '/brands/', $arSection['SECTION_PAGE_URL']);
- $brandsTreeDictionary[$arSection['ID']] = $arSection;
- }
- $CACHE_MANAGER->RegisterTag("iblock_id_new");
- $CACHE_MANAGER->EndTagCache();
- $cache->endDataCache($brandsTreeDictionary->toArray());
- }
- $arCurrentSection = $brandsTreeDictionary->get($currentSectionId);
- switch ($arCurrentSection['DEPTH_LEVEL'])
- {
- case '1':
- {
- $arBrandTree['TYPE'] = "BRAND";
- $arBrandTree['GAMMA'] = [];
- $arBrandTree['LINE'] = [];
- $arBrandTree['BRAND'] = $arCurrentSection;
- break;
- }
- case '2':
- {
- $arBrandTree['TYPE'] = "GAMMA";
- $arBrandTree['LINE'] = [];
- $arBrandTree['GAMMA'] = $arCurrentSection;
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- break;
- }
- case '3':
- {
- $arBrandTree['TYPE'] = "LINE";
- $arBrandTree['LINE'] = $arCurrentSection;
- $arBrandTree['GAMMA'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arBrandTree['GAMMA']['IBLOCK_SECTION_ID']);
- break;
- }
- }
- return $arBrandTree;
- }public static function getBrandTreeBySectionID($currentSectionId = "0")
- {
- $arBrandTree = ['BRAND' => [], 'GAMMA' => [], 'LINE' => [], 'TYPE' => ''];
- if (empty($currentSectionId))
- {
- return $arBrandTree;
- }
- $brandsTreeDictionary = new Dictionary();
- $cacheId = 'brandsTreeDictionary_' . self::CATALOG_IBLOCK_ID;
- $cacheDir = 'tagged_brands_tree';
- $cache = Cache::createInstance();
- if ($cache->initCache(14400, $cacheId, $cacheDir))
- {
- $brandsTreeDictionary->set($cache->getVars());
- }
- elseif ($cache->startDataCache())
- {
- $rCatalogSections = CIBlockSection::GetList([
- 'IBLOCK_ID' => self::CATALOG_IBLOCK_ID
- ], [
- 'ID',
- 'NAME',
- 'CODE',
- 'XML_ID',
- 'ACTIVE',
- 'SECTION_PAGE_URL',
- 'IBLOCK_SECTION_ID',
- 'DEPTH_LEVEL'
- ]);
- global $CACHE_MANAGER;
- $CACHE_MANAGER->StartTagCache($cacheDir);
- while ($arSection = $rCatalogSections->GetNext())
- {
- $CACHE_MANAGER->RegisterTag("iblock_id_".$arSection["ID"]."_".$arSection["IBLOCK_SECTION_ID"]);
- $arSection['SECTION_PAGE_URL'] = str_replace('/catalog/', '/brands/', $arSection['SECTION_PAGE_URL']);
- $brandsTreeDictionary[$arSection['ID']] = $arSection;
- }
- $CACHE_MANAGER->RegisterTag("iblock_id_new");
- $CACHE_MANAGER->EndTagCache();
- $cache->endDataCache($brandsTreeDictionary->toArray());
- }
- $arCurrentSection = $brandsTreeDictionary->get($currentSectionId);
- switch ($arCurrentSection['DEPTH_LEVEL'])
- {
- case '1':
- {
- $arBrandTree['TYPE'] = "BRAND";
- $arBrandTree['GAMMA'] = [];
- $arBrandTree['LINE'] = [];
- $arBrandTree['BRAND'] = $arCurrentSection;
- break;
- }
- case '2':
- {
- $arBrandTree['TYPE'] = "GAMMA";
- $arBrandTree['LINE'] = [];
- $arBrandTree['GAMMA'] = $arCurrentSection;
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- break;
- }
- case '3':
- {
- $arBrandTree['TYPE'] = "LINE";
- $arBrandTree['LINE'] = $arCurrentSection;
- $arBrandTree['GAMMA'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arBrandTree['GAMMA']['IBLOCK_SECTION_ID']);
- break;
- }
- }
- return $arBrandTree;
- }public static function getBrandTreeBySectionID($currentSectionId = "0")
- {
- $arBrandTree = ['BRAND' => [], 'GAMMA' => [], 'LINE' => [], 'TYPE' => ''];
- if (empty($currentSectionId))
- {
- return $arBrandTree;
- }
- $brandsTreeDictionary = new Dictionary();
- $cacheId = 'brandsTreeDictionary_' . self::CATALOG_IBLOCK_ID;
- $cacheDir = 'tagged_brands_tree';
- $cache = Cache::createInstance();
- if ($cache->initCache(14400, $cacheId, $cacheDir))
- {
- $brandsTreeDictionary->set($cache->getVars());
- }
- elseif ($cache->startDataCache())
- {
- $rCatalogSections = CIBlockSection::GetList([
- 'IBLOCK_ID' => self::CATALOG_IBLOCK_ID
- ], [
- 'ID',
- 'NAME',
- 'CODE',
- 'XML_ID',
- 'ACTIVE',
- 'SECTION_PAGE_URL',
- 'IBLOCK_SECTION_ID',
- 'DEPTH_LEVEL'
- ]);
- global $CACHE_MANAGER;
- $CACHE_MANAGER->StartTagCache($cacheDir);
- while ($arSection = $rCatalogSections->GetNext())
- {
- $CACHE_MANAGER->RegisterTag("iblock_id_".$arSection["ID"]."_".$arSection["IBLOCK_SECTION_ID"]);
- $arSection['SECTION_PAGE_URL'] = str_replace('/catalog/', '/brands/', $arSection['SECTION_PAGE_URL']);
- $brandsTreeDictionary[$arSection['ID']] = $arSection;
- }
- $CACHE_MANAGER->RegisterTag("iblock_id_new");
- $CACHE_MANAGER->EndTagCache();
- $cache->endDataCache($brandsTreeDictionary->toArray());
- }
- $arCurrentSection = $brandsTreeDictionary->get($currentSectionId);
- switch ($arCurrentSection['DEPTH_LEVEL'])
- {
- case '1':
- {
- $arBrandTree['TYPE'] = "BRAND";
- $arBrandTree['GAMMA'] = [];
- $arBrandTree['LINE'] = [];
- $arBrandTree['BRAND'] = $arCurrentSection;
- break;
- }
- case '2':
- {
- $arBrandTree['TYPE'] = "GAMMA";
- $arBrandTree['LINE'] = [];
- $arBrandTree['GAMMA'] = $arCurrentSection;
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- break;
- }
- case '3':
- {
- $arBrandTree['TYPE'] = "LINE";
- $arBrandTree['LINE'] = $arCurrentSection;
- $arBrandTree['GAMMA'] = $brandsTreeDictionary->get($arCurrentSection['IBLOCK_SECTION_ID']);
- $arBrandTree['BRAND'] = $brandsTreeDictionary->get($arBrandTree['GAMMA']['IBLOCK_SECTION_ID']);
- break;
- }
- }
- return $arBrandTree;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement