public IRecommendations GetRecommendedProducts(EntryContentBase catalogEntry, string userId, int maxCount) { if (catalogEntry == null) { throw new ArgumentNullException("catalogEntry"); } var client = SearchClient.Instance; string language = catalogEntry.Language.Name; string mainCategory = catalogEntry.GetMainCategory(language); string category = catalogEntry.GetCategoryName(language); var result = client.Search <FindProduct>() .Filter(x => x.CategoryName.Match(category)) .Filter(x => x.MainCategoryName.Match(mainCategory)) .Filter(x => !x.Code.Match(catalogEntry.Code)) .Filter(x => x.Language.Match(language)) .StaticallyCacheFor(TimeSpan.FromMinutes(1)) .Take(maxCount) .GetResult(); List <ContentReference> links = new List <ContentReference>(); foreach (FindProduct product in result) { links.Add(_referenceConverter.GetContentLink(product.Id, CatalogContentType.CatalogEntry, 0)); } IRecommendations recommendations = new Recommendations("RecForProduct", _contentRepository.GetItems(links, catalogEntry.Language)); return(recommendations); }
public FindProduct(EntryContentBase entryContentBase, string language) { IndexId = entryContentBase.ContentLink.ID + "_" + language; Id = entryContentBase.ContentLink.ID; Name = entryContentBase.Name; DisplayName = entryContentBase.DisplayName; Language = language; Description = Description ?? null; ParentCategoryId = entryContentBase.GetProductCategoryIds(language); ParentCategoryName = entryContentBase.GetParentCategoryNames(language); MainCategoryName = entryContentBase.GetMainCategory(language); CategoryName = entryContentBase.GetCategoryName(language); ProductUrl = urlResolverInjected.Service.GetUrl(entryContentBase.ContentLink, language); DefaultImageUrl = entryContentBase.GetDefaultImage(); }
public FindProduct(EntryContentBase entryContentBase, string language) { IndexId = entryContentBase.ContentLink.ID + "_" + language; Id = entryContentBase.ContentLink.ID; Code = entryContentBase.Code; Name = entryContentBase.Name; DisplayName = entryContentBase.DisplayName; Language = language; Description = Description ?? null; ParentCategoryId = entryContentBase.GetProductCategoryIds(language); ParentCategoryName = entryContentBase.GetParentCategoryNames(language); MainCategoryName = entryContentBase.GetMainCategory(language); CategoryName = entryContentBase.GetCategoryName(language); ProductUrl = urlResolverInjected.Service.GetUrl(entryContentBase.ContentLink, language); DefaultImageUrl = entryContentBase.GetDefaultImage(); }
public FindProduct(EntryContentBase entryContentBase, string language) { IndexId = entryContentBase.ContentLink.ID + "_" + language; Id = entryContentBase.ContentLink.ID; Code = entryContentBase.Code; Name = entryContentBase.Name; DisplayName = entryContentBase.DisplayName; Language = language; Description = Description ?? null; Overview = Overview ?? null; ParentCategoryId = entryContentBase.GetProductCategoryIds(language); ParentCategoryName = entryContentBase.GetParentCategoryNames(language); MainCategoryName = entryContentBase.GetMainCategory(language); CategoryName = entryContentBase.GetCategoryName(language); ProductUrl = _urlResolver.Service.GetUrl(entryContentBase.ContentLink, language); DefaultImageUrl = entryContentBase.GetDefaultImage(); AverageRating = entryContentBase.GetAverageRating(); DefaultInventory = entryContentBase.GetStock(); }