从 Nop 获取当前充满数据的 CategoryModel 到我的插件

Get current CategoryModel filled with data from Nop to my plugin

你能帮我解决以下问题吗?

我正在 nop commerce 中开发一个插件,我需要从 nop.web 获取当前的 CategoryModel。我如何才能将适当的数据填充到我的插件中? 我尝试使用

EngineContext.Current.Resolve<CategoryModel>();

但它fails.Hope很清楚。

提前致谢。

CategoryModel class 是一个数据实体,不能从服务定位器中注入或检索。

不清楚您要做什么,或者您是在管理后端还是在 public 前端工作(它们都有不同的 CategoryModel 实现)但是最喜欢的起点是获取类别服务的实例。

EngineContext.Current.Resolve<ICategoryService>();

然后从那里继续...

或者,根据您的实施,在 class 构造函数中使用 DI 来获取类别服务会更好。