Categories are extremely important to differentiate products in E-commerce stores. Whether it is small, medium or large-sized Magento 2 store, the categories help the store owner to separate products and services with category names.
After creating categories in Magento 2, while loading and debugging the category page, the Magento developers sometimes only get category ID in the URL. The category name should appear on the page.
Every category name contains a category ID. Manually finding bulk of the category names by category IDs from the backend is a time-consuming process.
Therefore, I have come up with a solution to get category name by category ID using SQL in Magento 2.
Programmatic Solution to Get Category Name by Category ID Using SQL in Magento 2
SELECT cce.entity_id as 'Category Id',
ccev.value as 'Category Name'
FROM `catalog_category_entity_varchar` ccev
ON cce.entity_id = ccev.entity_id
AND ccev.attribute_id =
WHERE attribute_code = 'name'
and entity_type_id =
WHERE entity_type_code = 'catalog_category'
) and cce.entity_id = < Your Category Id>
Done! Isn’t it simple?
If you have queries regarding the post, feel free to ask in the Comment section below.
I would like to solve your queries.
Also, do not forget to share this post with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.