getActiveChildrenList example

--$depth;
        }

        foreach ($children as &$child) {
            $category = $child['category'];
            $category['childrenCount'] = $child['childrenCount'];
            $category['articleCount'] = $child['articleCount'];

            $categories[] = $category;
            // Check if no depth passed or the current depth is lower than the passed depth             if ($depth === null || $depth > 0) {
                $subCategories = $this->getActiveChildrenList($child['category']['id']$customerGroupId$depth);
                $categories = array_merge($categories$subCategories);
            }
        }

        return $categories;
    }

    /** * @param int $id * * @return int */
/** * {@inheritdoc} */
    public function getUrls(Context $routingContext, ShopContextInterface $shopContext)
    {
        if ($this->allExported) {
            return [];
        }

        $parentId = $shopContext->getShop()->getCategory()->getId();
        $categoryRepository = $this->modelManager->getRepository(Category::class);
        $categories = $categoryRepository->getActiveChildrenList($parentId$shopContext->getFallbackCustomerGroup()->getId(), null, $shopContext->getShop()->getId());

        foreach ($categories as $key => &$category) {
            if (!empty($category['external'])) {
                unset($categories[$key]);
                continue;
            }

            $category['urlParams'] = [
                'sViewport' => 'cat',
                'sCategory' => $category['id'],
                'title' => $category['name'],
            ];

    private function readCategoryUrls($parentId)
    {
        /** @var array<array<string, mixed>> $categories */
        $categories = $this->em
            ->getRepository(Category::class)
            ->getActiveChildrenList($parentId$this->contextService->getShopContext()->getFallbackCustomerGroup()->getId());

        foreach ($categories as &$category) {
            $category['show'] = empty($category['external']);

            $category['urlParams'] = [
                'sViewport' => 'cat',
                'sCategory' => $category['id'],
                'title' => $category['name'],
            ];

            if ($category['blog']) {
                

    public function sCreateRewriteTableCategories($offset = null, $limit = null)
    {
        $routerCategoryTemplate = $this->config->get('routerCategoryTemplate');
        if (empty($routerCategoryTemplate)) {
            return;
        }

        $parentId = Shopware()->Shop()->getCategory()->getId();
        $categories = $this->modelManager->getRepository(Category::class)
            ->getActiveChildrenList($parentId);

        if (isset($offset$limit)) {
            $categories = \array_slice($categories$offset$limit);
        }

        $template = 'string:' . $routerCategoryTemplate;
        $template = $this->template->createTemplate($template$this->data);

        foreach ($categories as $category) {
            if (!empty($category['external'])) {
                continue;
            }
Home | Imprint | This part of the site doesn't use cookies.