1
votes

I am trying to create a Category Page specific CMS component.

Is there a currentCategoryService that is similar to the CurrentProductService in Spartacus injectables?

If not, what is the correct way to get the current category data (or at least the category code) in my new component?

1

1 Answers

3
votes

AFAIK, currently we do not have anything similar to CurrentProductService for current category. Looking at the implementation of CurrentProductService you can see that it is using RoutingService and it's getRouterState() method (picture 1). You can create something similar for current category, because the router state consists of category informations (as seen below on picture 2).

Picture 1: CurrentProductService:

enter image description here

Picture 2: Router state contents:

enter image description here