如何扩展NopCommerce CMS的GenericPathRoutecs

时间:2016-01-21 16:06:32

标签: c# asp.net-mvc nopcommerce

有没有办法从我的自定义插件扩展GenericPathRoute.cs GetRouteData(...)中支持的实体,以便我可以为自定义实体添加通用URL支持?

//process URL
            switch (urlRecord.EntityName.ToLowerInvariant())
            {
                case "product":
                    {
                        data.Values["controller"] = "Catalog";
                        data.Values["action"] = "Product";
                        data.Values["productid"] = urlRecord.EntityId;
                        data.Values["SeName"] = urlRecord.Slug;
                    }
                    break;
                 ...
                case "MyCustomEntity":

1 个答案:

答案 0 :(得分:1)

可以试试这个:

 <i>
 public class CmsCustomUrlRecordEntityNameRequested : IConsumer<CustomUrlRecordEntityNameRequested>
{

    void HandleEvent(CustomUrlRecordEntityNameRequested eventMessage)
    {
                            eventMessage.RouteData.Values["controller"] = "Topic";
                            eventMessage.RouteData.Values["action"] = "TopicDetails";
                            eventMessage.RouteData.Values["topicId"] = urlRecord.EntityId;
                            eventMessage.RouteData.Values["SeName"] = urlRecord.Slug;
    }

}

</i>