Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading