Search code examples
shopwareshopware6

How to show the category name as a title on the product listing page in Shopware 6?


The issue

In Shopware 6 I want to display the category name in a heading element on the top of the product listing page (next to the product description).

What I've tried

I thought this data would already exist somewhere, but I can't seem to find it. It only exists in the breadcrumbs or in the array of all navigation items. To use these values wouldn't be a logical solution nor a good solution in general. I tried to add {{ dump() }} in 'storefront/Resources/views/storefront/component/product/listing.html.twig' and look for the category name in the data.

What I would like

I expected there to be a 'Category entry' for the current category where all relevant data for the current category is stored, but this doesn't seem to exist.

Does anyone now a good way of displaying the category name in a heading element on the product listing page?


Solution

  • In your Twig template you can use

    page.header.navigation.active.translated.name
    

    Or in the shopping experience you can use mapping to map a text element to the category name. https://docs.shopware.com/en/shopware-6-en/content/ShoppingExperiences?category=shopware-6-en/content#blocks -> Text