Search code examples
shopwareshopware6

Shopware 6: How to display product name in breadcrumbs


We want to add the product name to the breadcrumb list when current page matches a product detail page. Unfortunately, it doesn't seem like the product is loaded yet when the breadcrumb is rendered. We have tried using dump() to see what variables are available and nothing related to the product.

Where should I look in order to include the product name in our breadcrumbs?


Solution

  • Have a look at storefront/base.html.twig. There you will see, that currently the breadcrumb-template gets passed the context and the category. If you want to also use some product-information, you have to overwrite this block like this:

    {% block base_breadcrumb %}
        {% sw_include '@Storefront/storefront/layout/breadcrumb.html.twig' with {
          context: context,
          category: page.product.seoCategory,
          product: page.product
        } only %}
    {% endblock %}
    

    Then you can use product in the breadcrumb-template.