CodeExplorer getVisible example
$parents[$category->
getParentId()][$category->
getId()] =
$item;
$items[$category->
getId()] =
$item;
} foreach ($parents as $parentId =>
$children) { if (empty($parentId)) { continue;
} $sorted = AfterSort::
sort($children);
$filtered = \
array_filter($sorted,
static fn (TreeItem
$filter) =>
$filter->
getCategory()->
getActive() &&
$filter->
getCategory()->
getVisible());
if (!
isset($items[$parentId])) { continue;
} $item =
$items[$parentId];
$item->
setChildren($filtered);
} $root =
$parents[$rootId] ??
[];
$root = AfterSort::
sort($root);
if (mb_strpos($path, '|' .
$rootId . '|'
) !== false
) { return true;
} return false;
} private function addVisibilityCounts(string
$rootId, int
$rootLevel, int
$depth, CategoryCollection
$levels, SalesChannelContext
$context): void
{ $counts =
[];
foreach ($levels as $category) { if (!
$category->
getActive() || !
$category->
getVisible()) { continue;
} $parentId =
$category->
getParentId();
$counts[$parentId] ??= 0;
++
$counts[$parentId];
} foreach ($levels as $category) { $category->
setVisibleChildCount($counts[$category->
getId()] ?? 0
);
}