$depth =
$request->query->
getInt('depth',
$request->request->
getInt('depth', 2
));
$metaInfo =
$this->
getCategoryMetaInfo($activeId,
$rootId);
$active =
$this->
getMetaInfoById($activeId,
$metaInfo);
$root =
$this->
getMetaInfoById($rootId,
$metaInfo);
// Validate the provided category is part of the sales channel
$this->
validate($activeId,
$active['path'
],
$context);
$isChild =
$this->
isChildCategory($activeId,
$active['path'
],
$rootId);
// If the provided activeId is not part of the rootId, a fallback to the rootId must be made here.
// The passed activeId is therefore part of another navigation and must therefore not be loaded.
// The availability validation has already been done in the `validate` function.
if (!
$isChild) { $activeId =
$rootId;
} $categories =
new CategoryCollection();
if ($depth > 0
) { // Load the first two levels without using the activeId in the query