using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Core.Caching;
using Nop.Core.Domain.Catalog;
using Nop.Plugin.Widgets.MegaMenu.Models;
using Nop.Services.Catalog;
using Nop.Services.Configuration;
using Nop.Services.Media;
using Nop.Web.Framework.Components;
using System.Linq;
namespace Nop.Plugin.Widgets.MegaMenu.Components
{
[ViewComponent(Name = "MegaMenu")]
public class MegaMenuViewComponent : NopViewComponent
{
private readonly IStoreContext _storeContext;
private readonly IStaticCacheManager _cacheManager;
private readonly ISettingService _settingService;
private readonly IPictureService _pictureService;
private readonly ICategoryService _categoryService;
public MegaMenuViewComponent(IStoreContext storeContext,
IStaticCacheManager cacheManager,
ISettingService settingService,
IPictureService pictureService,
ICategoryService categoryService)
{
this._storeContext = storeContext;
this._cacheManager = cacheManager;
this._settingService = settingService;
this._pictureService = pictureService;
this._categoryService = categoryService;
}
public IViewComponentResult Invoke(string widgetZone, object additionalData)
{
var mCategories = new PublicInfoModel();
var allCategories = _categoryService.GetAllCategories().Where(x => x.IncludeInTopMenu == true);
Solved. There is a bug in nopcommerce 4.1 for ICategoryService
The implementation in ICategoryService.cs for Nop.Service.Catalog;
public partial interface IList
{
Changed to:
public partial interface ICategoryService
{
Cleaned and Rebuilt Solution and all is working. Did nopCommerce forget to rename the service or is it name IList on purpose???