public WidgetsVendorDetailsController(IWorkContext workContext, IPermissionService permissionService, IVendorService vendorService, IProductService productService, CatalogSettings catalogSettings, ISettingService settingService, IStoreService storeService, ILocalizationService localizationService, VendorDetailsSettings vendorDetailsSettings ) { this._permissionService = permissionService; this._vendorService = vendorService; this._workContext = workContext; this._productService = productService; this._catalogSettings = catalogSettings; this._settingService = settingService; this._storeService = storeService; this._vendorDetailsSettings = vendorDetailsSettings; this._localizationService = localizationService; }
public IViewComponentResult Invoke(string widgetZone, object additionalData) { IViewComponentResult viewComponent; EmptyResult emptyResult = new EmptyResult(); VendorDetailsSettings VendorDetailsSetting = _settingService.LoadSetting <VendorDetailsSettings>(_storeContext.CurrentStore.Id); if (VendorDetailsSetting != null) { int productId = Convert.ToInt32(additionalData); if (productId != 0) { var P = _customersInfo.GetCount(productId); Product productById = _productService.GetProductById(productId); if (productById == null ? false : productById.VendorId == 0) { PublicInfoModel yom = new PublicInfoModel(); yom.Name = productById.Name; yom.SoldCount = P.Count; PublicInfoModel email1 = yom; viewComponent = base.View("~/Plugins/Widgets.VendorDetails/Views/raw.cshtml", email1); } else if (productById == null ? false : productById.VendorId != 0) { var VendorIds = this._vendorService.GetVendorById(productById.VendorId).Id; var CustomerIds = _customersInfo.GetCustomerId(VendorIds); Vendor vendorById = this._vendorService.GetVendorById(productById.VendorId); PublicInfoModel Model = new PublicInfoModel(); //Model.Id(vendorById.get_Id()); Model.Name = vendorById.Name; Model.Description = vendorById.Description; //Model.Rating = productById.ApprovedRatingSum; //Model.SoldCount = P.Count; //Model.Phone = CustomerIds.GetAttribute<String>(SystemCustomerAttributeNames.Phone); Model.SeName = SeoExtensions.GetSeName(vendorById); PublicInfoModel email = Model; if (VendorDetailsSetting.ShowVendorEmail) { email.Email = vendorById.Email; } if (VendorDetailsSetting.ShowProductRating) { email.Rating = productById.ApprovedRatingSum; } if (VendorDetailsSetting.ShowProductSoldCount) { email.SoldCount = P.Count; } if (VendorDetailsSetting.ShowVendorPhoneNumer) { email.Phone = CustomerIds.GetAttribute <String>(SystemCustomerAttributeNames.Phone); } viewComponent = base.View("~/Plugins/Widgets.VendorDetails/Views/PublicInfo.cshtml", email); } else { viewComponent = null; } } else { viewComponent = null; } } else { viewComponent = null; } return(viewComponent); }