Development Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi all,
I am new in Nopcommerce. Could you please help me in this. or suggest me which assembly should i add?

I am getting following error.

*****Controller*****

public virtual ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            var model = new ProductListModel();
            //a vendor should have access only to his products
            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
            model.AllowVendorsToImportProducts = _vendorSettings.AllowVendorsToImportProducts;

            //categories
            model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            var categories = SelectListHelper.GetCategoryList(_categoryService, _cacheManager, true);
            foreach (var c in categories)
                model.AvailableCategories.Add(c);

            //manufacturers
            model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            var manufacturers = SelectListHelper.GetManufacturerList(_manufacturerService, _cacheManager, true);
            foreach (var m in manufacturers)
                model.AvailableManufacturers.Add(m);

            //stores
            model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            foreach (var s in _storeService.GetAllStores())
                model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() });

            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            foreach (var wh in _shippingService.GetAllWarehouses())
                model.AvailableWarehouses.Add(new SelectListItem { Text = wh.Name, Value = wh.Id.ToString() });

            //vendors
            model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            var vendors = SelectListHelper.GetVendorList(_vendorService, _cacheManager, true);
            foreach (var v in vendors)
                model.AvailableVendors.Add(v);

            //product types
            model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList();
            model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });

            //"published" property
            //0 - all (according to "ShowHidden" parameter)
            //1 - published only
            //2 - unpublished only
            model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.All"), Value = "0" });
            model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.PublishedOnly"), Value = "1" });
            model.AvailablePublishedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.Products.List.SearchPublished.UnpublishedOnly"), Value = "2" });

            return View("~/Plugins/Products.MultipleGtin/Views/List.cshtml", model);
        }


******View*******

@model Nop.Admin.Models.Catalog.ProductListModel

@using Nop.Core.Domain.Catalog
@using Nop.Core.Infrastructure
@using Nop.Web.Framework

@{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    //page title
    ViewBag.Title = T("Admin.Catalog.Products").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Products");
}


Return this error

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Nop.Admin.Models.Catalog.ProductListModel>' does not contain a definition for 'SetActiveMenuItemSystemName' and no extension method 'SetActiveMenuItemSystemName' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Nop.Admin.Models.Catalog.ProductListModel>' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 11:     ViewBag.Title = T("Admin.Catalog.Products").Text;
Line 12:     //active menu item (system name)
Line 13:     Html.SetActiveMenuItemSystemName("Products");
Line 14: }
Line 15:


Thank all
Giampiero
6 years ago
Hi,

Please add @using Nop.Web.Framework.UI to the view :)

Regards
Krzysztof
6 years ago
Thank you Krzysztof
you are the Best! ;-)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.