detectRootId example

$criteria->addFilter(
            new EqualsFilter('active', true),
        );
    }

    public function getMapping(Entity $category, ?SalesChannelEntity $salesChannel): SeoUrlMapping
    {
        if (!$category instanceof CategoryEntity) {
            throw new \InvalidArgumentException('Expected CategoryEntity');
        }

        $rootId = $this->detectRootId($category$salesChannel);

        $breadcrumbs = $this->breadcrumbBuilder->build($category$salesChannel$rootId);
        $categoryJson = $category->jsonSerialize();
        $categoryJson['seoBreadcrumb'] = $breadcrumbs;

        $error = null;
        if (!$rootId) {
            $error = 'Category is not available for sales channel';
        }

        return new SeoUrlMapping(
            
Home | Imprint | This part of the site doesn't use cookies.