Nop 3.7
I'm looking to spruce up the Sitemap.cshtml page. Right now it's pretty horrible in it's structure. I want to include the main categories and under them the sub categories but the SitemapModel does not contain ParentCategoryId. Nor does the CategoryModel that is within the SitemapModel. I have made modifications.
Nop.Core.Domain.Catalog Category.cs already contains ParentCategoryId
Nop.Data.Catalog CategoryMap.cs modification
this.Property(c => c.ParentCategoryId).IsRequired();
Nop.Web.Models.Catalog CategoryModel.cs modification
public int ParentCategoryId { get; set; }
Sitemap.cshtml SitemapModel CategoryModel now has the property ParentCategoryId The below code pulls the correct main categories but will not pull in the subcategories
@if (Model.Categories.Count > 0)
{
List<int> mainCategories = new List<int>
{ 2799, 3869, 3302, 2862, 298, 3451, 2809, 2828, 3001, 3319, 303, 207, 2793 };
int numItems = mainCategories.Count();
<div class="page-header-custom">
<h4>@T("Sitemap.Categories")</h4>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="list-group">
@for (int i = 0; i < numItems; i++)
{
foreach (var category in Model.Categories.Where(x => x.Id == mainCategories[i]))
{
<a class="" href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name</a>
foreach (var subCategory in Model.Categories.Where(x => x.ParentCategoryId == mainCategories[i]))
{
<a class="" href="@Url.RouteUrl("Category", new { SeName = subCategory.SeName })">@subCategory.Name</a>
}
}
}
</div>
</div>
</div>
}
Anyone know why this is not working?
Does the controller need to be modified as well and if so how?
Thanks