diff --git a/meta/documents/changelog_de.md b/meta/documents/changelog_de.md
index 6e750be01..4fc7b8020 100644
--- a/meta/documents/changelog_de.md
+++ b/meta/documents/changelog_de.md
@@ -6,6 +6,10 @@
- Eine Möglichkeit zur Filterung der Herstellerdaten wurde hinzugefügt.
+### Geändert
+
+- Der CategoryService benutzt jetzt eine Kernfunktion zur Ermittlung des Navigationsbaum. Dies führt zu einer besseren Performance.
+
## v5.0.68 (2024-09-26) Übersicht aller Änderungen
### Behoben
diff --git a/meta/documents/changelog_en.md b/meta/documents/changelog_en.md
index 387d63de3..eae9c5a03 100644
--- a/meta/documents/changelog_en.md
+++ b/meta/documents/changelog_en.md
@@ -12,6 +12,10 @@
- Added an additional check for displaying the tracking link to ensure that the tracking link is only shown for shipping providers with tracking URLs.
+### Changed
+
+- The category service is now using a core method to get the navigation tree. This change improves the performance.
+
## v5.0.64 (2024-08-19) Overview of all changes
### Changed
diff --git a/src/Services/CategoryService.php b/src/Services/CategoryService.php
index caa49afc5..ac1083571 100644
--- a/src/Services/CategoryService.php
+++ b/src/Services/CategoryService.php
@@ -98,8 +98,7 @@ public function __construct(
ContactRepositoryContract $contactRepository,
UrlBuilderRepositoryContract $urlBuilderRepository,
WebshopCategoryRepositoryContract $webshopCategoryRepositoryContract
- )
- {
+ ) {
$this->categoryRepository = $categoryRepository;
$this->webstoreConfigurationRepository = $webstoreConfigurationRepository;
$this->authGuard = $authGuard;
@@ -141,7 +140,7 @@ public function setCurrentCategory($cat)
while ($cat !== null) {
$this->currentCategoryTree[$cat->level] = $cat;
- if($cat->parentCategoryId != null){
+ if ($cat->parentCategoryId != null) {
$cat = $this->webshopCategoryRepository->get($cat->parentCategoryId, $lang, $this->webstoreId);
} else {
$cat = null;
@@ -168,7 +167,7 @@ public function getCurrentCategory()
*/
public function get($catID = 0, $lang = null)
{
- if(is_null($catID) || strlen($catID) == 0) {
+ if (is_null($catID) || strlen($catID) == 0) {
return null;
}
@@ -467,39 +466,14 @@ public function getNavigationTree(
string $lang = null,
int $maxLevel = 2,
int $customerClassId = 0
- ): array
- {
- if (is_array($type) && count($type) === 0) {
- return [];
- }
-
- if ($lang === null) {
- $lang = Utils::getLang();
- }
-
- if (is_null($type)) {
- $type = CategoryType::ALL;
- }
-
- $tree = $this->categoryRepository->getArrayTree(
- $type,
+ ): array {
+ return $this->webshopCategoryRepository->getNavigationTree(
+ $type ?? ['all'],
$lang,
$this->webstoreConfigurationRepository->getWebstoreConfiguration()->webstoreId,
$maxLevel,
$customerClassId,
- function ($category) {
- return $category['linklist'] == 'Y';
- }
- );
-
- if (Utils::isContactLoggedIn() === false && Utils::isAdminPreview() === false) {
- $tree = $this->filterVisibleCategories($tree);
- }
-
- $categoryDataFilter = pluginApp(CategoryDataFilter::class);
- return $categoryDataFilter->applyResultFields(
- $tree,
- ResultFieldTemplate::load(ResultFieldTemplate::TEMPLATE_CATEGORY_TREE)
+ ResultFieldTemplate::TEMPLATE_CATEGORY_TREE
);
}
@@ -611,7 +585,6 @@ public function getNavigationList($type = CategoryType::ALL, string $lang = null
public function getHierarchy(int $catID = 0, bool $bottomUp = false, bool $filterCategories = false, $restoreOldValues = false): array
{
if ($catID > 0) {
-
if ($restoreOldValues) {
$oldCategory = $this->currentCategory;
$oldCategoryTree = $this->currentCategoryTree;
@@ -821,12 +794,11 @@ private function filterCategoriesByTypes($categoryList = [], $types = CategoryTy
$loggedIn = Utils::isContactLoggedIn();
$result = array_filter(
$categoryList,
-
function ($category) use ($types, $loggedIn) {
return in_array(
- $category->type,
- $types
- ) && ($category->right !== 'customer' || $loggedIn || Utils::isAdminPreview());
+ $category->type,
+ $types
+ ) && ($category->right !== 'customer' || $loggedIn || Utils::isAdminPreview());
}
);