private function addBreadcrumbs(ProductInterface $product) { $category = $product->getCategories()->last(); $paths = $this->get('category.repository')->getCategoryPath($category); /** @var CategoryInterface $path */ foreach ($paths as $path) { $this->getBreadcrumbProvider()->add(new Breadcrumb(['label' => $path->translate()->getName(), 'url' => $this->getRouterHelper()->generateUrl($path->translate()->getRoute()->getId())])); } $this->getBreadcrumbProvider()->add(new Breadcrumb(['label' => $product->translate()->getName()])); }