2017-06-12 47 views
1

我是nopcommerce插件开发的新手,但学习速度非常快。Nopcommerce小部件插件戴尔

我正在开发一个小部件插件来显示产品详细信息页面上的供应商信息框,但我遇到了一些问题,产品页面停止显示并抛出错误。

下面,在这个问题将是我的代码和产品页面错误的图片。

位指示:

[ChildActionOnly] 
public ActionResult PublicInfo(string widgetZone, Vendor vm, object additionalData) 
{ 
     ActionResult actionResult; 
     EmptyResult emptyResult = new EmptyResult(); 
     var activeStoreScopeConfiguration = this.GetActiveStoreScopeConfiguration(this._storeService, this._workContext); 
     VendorDetailsSettings VendorDetailsSetting = _settingService.LoadSetting<VendorDetailsSettings>(activeStoreScopeConfiguration); 
     if (VendorDetailsSetting != null) 
     { 
      int QproductId = Convert.ToInt32(System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values["productId"]); 


      var productId = Convert.ToInt32(additionalData); 
      if (productId != 0) 
      { 
       Product productById = _productService.GetProductById(productId); 
       if (productById == null ? false : productById.VendorId != 0) 
       { 
        Vendor vendorById = _vendorService.GetVendorById(productById.VendorId); 

        if (vendorById == null || vendorById.Deleted ? false : vendorById.Active) 
        { 
         var Model = new PublicInfoModel(); 
         //Model.Id = vendorById.Id; 
         ParameterExpression parameterExpression = Expression.Parameter(typeof(Vendor), "x"); 
         Model.Name = LocalizationExtensions.GetLocalized<Vendor>(vendorById, Expression.Lambda<Func<Vendor, string>>(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(Vendor).GetMethod("Name").MethodHandle)), new ParameterExpression[] { parameterExpression })); 
         parameterExpression = Expression.Parameter(typeof(Vendor), "x"); 
         Model.Description = LocalizationExtensions.GetLocalized<Vendor>(vendorById, Expression.Lambda<Func<Vendor, string>>(Expression.Property(parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(typeof(Vendor).GetMethod("Description").MethodHandle)), new ParameterExpression[] { parameterExpression })); 
         Model.SeName = SeoExtensions.GetSeName<Vendor>(vendorById); 
         PublicInfoModel model = Model; 
         if (VendorDetailsSetting.ShowVendorEmail || VendorDetailsSetting.ShowVendorPhoneNumer || VendorDetailsSetting.ShowVendorVendorRating) 
         { 
          model.Email = vendorById.Email; 


         } 
         return View("~/Plugins/Widgets.VendorDetails/Views/PublicInfo.cshtml", model); 
        } 
        else 
        { 
         actionResult = emptyResult; 
        } 
       } 
       else 
       { 
        actionResult = emptyResult; 
       } 
      } 
      else 
      { 
       actionResult = emptyResult; 
      } 
     } 
     else 
     { 
      actionResult = emptyResult; 
     } 
     return actionResult; 
    } 

Plugin.cs:

public IList<string> GetWidgetZones() 
{ 
    return string.IsNullOrEmpty(_vendorDetailsSettings.WidgetZone) ? new List<string>() : new List<string> { _vendorDetailsSettings.WidgetZone }; 
} 


public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) 
{ 
    actionName = "Configure"; 
    controllerName = "WidgetsVendorDetails"; 
    routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Widgets.VendorDetails.Controllers" }, { "area", null } }; 
} 

/// <summary> 
/// Gets a route for displaying widget 
/// </summary> 
/// <param name="widgetZone">Widget zone where it's displayed</param> 
/// <param name="actionName">Action name</param> 
/// <param name="controllerName">Controller name</param> 
/// <param name="routeValues">Route values</param> 
public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out RouteValueDictionary routeValues) 
{ 
    actionName = "PublicInfo"; 
    controllerName = "WidgetsVendoDetails"; 
    routeValues = new RouteValueDictionary 
    { 
     {"Namespaces", "Nop.Plugin.Widgets.VendorDetails.Controllers"}, 
     {"area", null}, 
     {"widgetZone", widgetZone} 
    }; 
} 


public override void Install() 
{ 
    var settings = new VendorDetailsSettings 
    { 
     WidgetZone = "productbox_add_info" 
    }; 
    _settingService.SaveSetting(settings); 
    base.Install(); 
} 

public override void Uninstall() 
{ 
    _settingService.DeleteSetting<VendorDetailsSettings>(); 
    base.Uninstall(); 
} 
} 
+0

你的错误是什么? – Fabiano

回答

0

错误是在产品页面没有实现IControllers ...但我已经解决了它..通过返回基地。查看()而不是视图... 谢谢。