- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2020
07:02 AM
12-31-2020
07:02 AM
Get Current Product Category Name/ID
Hey everyone,
I am brand new to magento 2 so forgive me if this is pretty basic. I am using magento 2.3 and am having issues researching or finding a solution for something that seems super simple. I just need to grab the category name or ID of the current product I am viewing so I can add it to a data attribute in the html.
Only solution I found that worked was using the object manager which I read is a bad thing to do. The other solutions used the registry which is deprecated.
Any help would be appreciated.
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021
10:21 PM
01-05-2021
10:21 PM
Re: Get Current Product Category Name/ID
Hello @beartheset7958
I hope I have solution for this.
Checkout this articles:
How to Get Current Product in Magento 2
How to Get Current Category in Magento 2
Hope this helps you .
Thank-You