protected function sCreateRewriteTableCategories() { if (empty($this->sSYSTEM->sCONFIG['sROUTERCATEGORYTEMPLATE'])) { return; } $parentId = $this->baseCategory->getId(); $result = $this->repository->getActiveChildrenByIdQuery($parentId)->getArrayResult(); $categories = array(); foreach ($result as $category) { $categories[$category['category']['id']] = array_merge($category['category'], array('description' => $category['category']['name'], 'childrenCount' => $category['childrenCount'], 'articleCount' => $category['articleCount'])); } foreach ($categories as $category) { if (!empty($category['external'])) { continue; } $this->data->assign('sCategory', $category); $path = $this->template->fetch('string:' . $this->sSYSTEM->sCONFIG['sROUTERCATEGORYTEMPLATE'], $this->data); $path = $this->sCleanupPath($path, false); if ($category['blog']) { $orgPath = 'sViewport=blog&sCategory=' . $category['id']; } else { $orgPath = 'sViewport=cat&sCategory=' . $category['id']; } $this->sInsertUrl($orgPath, $path); } }
/** * Return a whole category tree by id * @param int $parentId * @param null $depth * @return array */ public function sGetWholeCategoryTree($parentId = null, $depth = null) { if ($parentId === null) { $parentId = $this->baseId; } $result = $this->repository->getActiveChildrenByIdQuery($parentId, $this->customerGroupId, $depth)->getArrayResult(); $categories = array(); foreach ($result as $category) { $url = $category['category']['blog'] ? $this->blogBaseUrl : $this->baseUrl; $categories[$category['category']['id']] = array_merge($category['category'], array('description' => $category['category']['name'], 'childrenCount' => $category['childrenCount'], 'articleCount' => $category['articleCount'], 'hidetop' => $category['category']['hideTop'], 'link' => $category['category']['external'] ?: $url . $category['category']['id'])); } $categories = $this->repository->buildTree($categories, array('childrenField' => 'sub')); return $categories; }