Open Stephanie-Spears opened 5 years ago
Hi Stephanie
You need to add your PublishedContent as a parameter for the new CategoryModel()
you have.
This should work.
public class CategoryController : RenderMvcController
{
//Basic Product
public override ActionResult Index(RenderModel model)
{
LogHelper.Info<CategoryController>("Hello, we have a custom model in category.");
return View(new CategoryModel(model.Content));
}
}
public class CategoryModel : RenderModel
{
public List<ProductDetailsModel> categoryList;
public CategoryModel()
: base(UmbracoContext.Current.PublishedContentRequest.PublishedContent)
{
categoryList = NopCommerceService.Instance.GetNopProducts().Products;
}
}
The Error: Umbraco.Web.UmbracoContext.PublishedContentRequest.get returned null
The code: