private IList <FullTextSearchResultDTO> ConvertToFullTextSearchResultModel(ResultSet <Product> products, Guid?productDetailsPageId) { var fullTextSearchResultModels = new List <FullTextSearchResultDTO>(); if (products == null || !products.Any()) { return(fullTextSearchResultModels); } var currencyIsoCode = CatalogContext.CurrentPriceGroup.CurrencyISOCode; var productsPrices = CatalogLibrary.CalculatePrices(products.Select(x => x.Guid).ToList()).Items; var catalog = CatalogContext.CurrentCatalog; foreach (var product in products) { string catUrl = string.Empty; if (product.Categories != null && product.Categories.Any()) { var productCategoryId = catalog.Categories.FirstOrDefault(x => product.Categories.Any(c => c == x)); if (productCategoryId != Guid.Empty) { var category = CatalogContext.CurrentCategories.FirstOrDefault(x => x.Guid == productCategoryId); catUrl = CategoryModel.GetCategoryPath(category); } } if (string.IsNullOrWhiteSpace(catUrl)) { catUrl = CategoryModel.DefaultCategoryName; } string detailsPageUrl = string.Empty; if (productDetailsPageId != null && productDetailsPageId.Value != Guid.Empty) { detailsPageUrl = Pages.UrlResolver.GetPageNodeUrl(productDetailsPageId.Value); if (!detailsPageUrl.EndsWith("/")) { detailsPageUrl += "/"; } detailsPageUrl += $"{catUrl}/p/{product.Slug}"; detailsPageUrl = Pages.UrlResolver.GetAbsoluteUrl(detailsPageUrl); } if (string.IsNullOrWhiteSpace(detailsPageUrl)) { detailsPageUrl = UrlService.GetUrl(CatalogContext.CurrentCatalog, product); } var price = string.Empty; if (productsPrices?.FirstOrDefault(x => x.ProductGuid == product.Guid)?.PriceInclTax != null) { price = new Money(productsPrices.First(x => x.ProductGuid == product.Guid).PriceInclTax, currencyIsoCode).ToString(); } var fullTestSearchResultModel = new FullTextSearchResultDTO() { ThumbnailImageUrl = product.ThumbnailImageUrl, Name = product.Name, Url = detailsPageUrl, Price = new Money(productsPrices.First(x => x.ProductGuid == product.Guid).PriceInclTax, currencyIsoCode).ToString(), }; fullTextSearchResultModels.Add(fullTestSearchResultModel); } return(fullTextSearchResultModels); }