getCategoryChildrenIds example

'children' => $page['children'],
        ]);
    }

    /** * Helper function to return the category information by category id * * @return array<string, mixed> */
    private function getCategoryById(int $categoryId): array
    {
        $childrenIds = $this->getCategoryChildrenIds($categoryId);
        $childrenIds[] = $categoryId;

        $context = $this->container->get(ContextServiceInterface::class)->getShopContext();
        $categories = $this->container->get(CategoryServiceInterface::class)->getList($childrenIds$context);

        $converted = [];
        foreach ($categories as $category) {
            $temp = $this->container->get(LegacyStructConverter::class)->convertCategoryStruct($category);
            $childrenIds = $this->getCategoryChildrenIds($category->getId());
            $temp['childrenCount'] = \count($childrenIds);
            $converted[$category->getId()] = $temp;
        }
Home | Imprint | This part of the site doesn't use cookies.