Posted on

How to get product parent category id and category id separatly in magento 2.2.6 using product ID?

Problem definition:

I have product under below category:

Beauty –> Sun –> my-some-product-name.

where ‘Beauty’ is root category and ‘Sun’ is the subcategory of ‘Beauty’.

Currently, I am trying to get root category id and subcategory id of product separately.

How to get above data in Magento 2.2.6 product ID?

Leave a Reply

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