getMainCategory example

if ($pos !== false) {
                // Remove all breadcrumbs preceding the navigation category                 return \array_slice($categoryBreadcrumb$pos + 1);
            }
        }

        return $categoryBreadcrumb;
    }

    public function getProductSeoCategory(ProductEntity $product, SalesChannelContext $context): ?CategoryEntity
    {
        $category = $this->getMainCategory($product$context);

        if ($category !== null) {
            return $category;
        }

        $categoryIds = $product->getCategoryIds() ?? [];
        $productStreamIds = $product->getStreamIds() ?? [];

        if (empty($productStreamIds) && empty($categoryIds)) {
            return null;
        }

        
Home | Imprint | This part of the site doesn't use cookies.