Reputation: 7598
I am creating a new theme in nopcommerce,
I want to print all categories in view,
I have wrote follwing code to retrieve all subcategories within a cartegory,
This call(on line 2) fails with Object reference not set to instance of onject
error.
var _engine = new NopEngine();
var categoryService = _engine.Resolve<ICategoryService>();
var L1Categories = from p in categoryService.GetAllCategoriesByParentCategoryId(24)
where (p.Deleted==false)
select p;
Upvotes: 2
Views: 171
Reputation: 3439
You should use the following code to resolve ICategoryService:
var categoryService = EngineContext.Current.Resolve<ICategoryService>();
Do not forget to add appropriate "using" directives
Upvotes: 4