services

Breadcrumb_builder_custom.php
  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return $route_match->getRouteName() == 'commerce_cart.page';
  }

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {
    // Node ID from shop
    $node = $this->entityTypeManager->getStorage('node')->load(3337);

    $breadcrumb = new Breadcrumb();
    $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
    $breadcrumb->addLink(Link::fromTextAndUrl($node->getTitle(), $node->toUrl()));

    return $breadcrumb;
  }
10.07.2025 | Lothar Ferreira Neumann, Mathias Grab

Manipulate breadcrumbs with custom logic