How to get Current Category data in magento 2?

Current Category collection can be found if you are in category page otherwise you can’t get current category collection using Registry. Refer below code snippet for getting current category collection in Magento 2,

Call From template file,

If you are in category page, you got Current category details by above code snippet otherwise display the message like,Current page is not a category page

Leave a Reply

Your email address will not be published. Required fields are marked *