public GetAutocompleteProductResults_Brasseler(AutocompleteSettings autocompleteSettings, CatalogGeneralSettings catalogGeneralSettings, ICatalogPathBuilder catalogPathBuilder, IProductSearchProvider productSearchProvider, IProductService productService) { this.autocompleteSettings = autocompleteSettings; this.catalogGeneralSettings = catalogGeneralSettings; this.catalogPathBuilder = catalogPathBuilder; this.productSearchProvider = productSearchProvider; this.productService = productService; }
public override GetAutocompleteResult Execute(IUnitOfWork unitOfWork, GetAutocompleteParameter parameter, GetAutocompleteResult result) { if (!this.autocompleteSettings.ProductEnabled || !parameter.ProductEnabled || parameter.Query.IsBlank()) { return(this.NextHandler.Execute(unitOfWork, parameter, result)); } GetProductSettingsResult settings = this.productService.GetSettings(new GetSettingsParameter()); if (settings.ResultCode != ResultCode.Success) { return(this.CreateErrorServiceResult <GetAutocompleteResult>(result, settings.SubCode, settings.Message)); } if (!settings.CanSeeProducts) { return(this.CreateErrorServiceResult <GetAutocompleteResult>(result, SubCode.Forbidden, MessageProvider.Current.Forbidden)); } int maximumNumber = Math.Max(Math.Min(this.autocompleteSettings.ProductLimit, this.MaximumAutocompleteResults), this.MinimumAutocompleteResults); ProductSearchResult autocompleteSearchResults = this.productSearchProvider.GetAutocompleteSearchResults(parameter.Query, maximumNumber); result.Products = autocompleteSearchResults.Products.Select <ProductSearchResultDto, GetProductAutocompleteItemResult>((Func <ProductSearchResultDto, GetProductAutocompleteItemResult>)(o => { GetProductAutocompleteItemResult autocompleteItemResult = new GetProductAutocompleteItemResult(); autocompleteItemResult.Id = new Guid?(o.Id); autocompleteItemResult.Image = o.MediumImagePath ?? this.catalogGeneralSettings.NotFoundMediumImagePath; autocompleteItemResult.IsNameCustomerOverride = o.IsNameCustomerOverride; autocompleteItemResult.ManufacturerItemNumber = o.ManufacturerItemNumber; autocompleteItemResult.Name = o.Name; autocompleteItemResult.ErpNumber = o.ERPNumber; autocompleteItemResult.Title = o.ShortDescription; ICatalogPathBuilder catalogPathBuilder = this.catalogPathBuilder; Product product = new Product(); product.Id = o.Id; product.UrlSegment = o.UrlSegment; // ISSUE: variable of the null type dynamic local = null; autocompleteItemResult.Url = catalogPathBuilder.MakeCanonicalProductUrlPath(product, (Language)local); if (unitOfWork.GetTypedRepository <IProductRepository>().Get((Guid)o.Id).Unspsc != null) { autocompleteItemResult.Properties["Unspsc"] = unitOfWork.GetTypedRepository <IProductRepository>().Get((Guid)o.Id).Unspsc; } else { autocompleteItemResult.Properties["Unspsc"] = string.Empty; } return(autocompleteItemResult); })).ToList <GetProductAutocompleteItemResult>(); return(this.NextHandler.Execute(unitOfWork, parameter, result)); }
public RetrievePageService( ICatalogPathBuilder catalogPathBuilder, ICatalogService catalogService, INavigationFilterService navigationFilterService, IContentModeProvider contentModeProvider, ISiteContextServiceFactory siteContextServiceFactory, Lazy <ICatalogPathFinder> catalogPathFinder, IRulesEngine rulesEngine, IHtmlRedirectPipeline htmlRedirectPipeline) { this.catalogPathBuilder = catalogPathBuilder; this.catalogService = catalogService; this.navigationFilterService = navigationFilterService; this.contentModeProvider = contentModeProvider; this.siteContextService = siteContextServiceFactory.GetSiteContextService(); this.catalogPathFinder = catalogPathFinder; this.rulesEngine = rulesEngine; this.htmlRedirectPipeline = htmlRedirectPipeline; }