Get Parent Category Name

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello,

Is it possible to get the parent category name and ID to use in the _ProductBox.cshtml file.

I found some code on the forum to get the Current Category Name but couldn't figure out how to get the parent.

Cheers
7 years ago
JHopper wrote:
Hello,

Is it possible to get the parent category name and ID to use in the _ProductBox.cshtml file.

I found some code on the forum to get the Current Category Name but couldn't figure out how to get the parent.

Cheers


Yes. possible. When you retrieve product default category(get the Current Category Name) there has parent category id. So you can retrieve that parent category too.
7 years ago
I have tried using this

Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Catalog.ICategoryService>().GetAllCategoriesByParentCategoryId(currentProductId);

but it returned System.Collections.Generic.List`1[Nop.Core.Domain.Catalog.Category]

Kind of lost with it all!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.