Esempio n. 1
0
        /// <summary>
        /// Sets Featured Product property and Best Bet Product property to ProductViewModels.
        /// </summary>
        /// <param name="searchResult">The search result (product list).</param>
        /// <param name="currentContent">The product category.</param>
        /// <param name="searchQuery">The search query string to filter Best Bet result.</param>
        /// <param name="productViewModels">The ProductViewModels is added two properties: Featured Product and Best Bet.</param>
        private void ApplyBoostedProperties(ref List <ProductTileViewModel> productViewModels, IContentResult <EntryContentBase> searchResult, IContent currentContent, string searchQuery)
        {
            var node     = currentContent as GenericNode;
            var products = new List <EntryContentBase>();

            if (node != null)
            {
                //products = node.FeaturedProducts?.FilteredItems?.Select(x => x.GetContent() as EntryContentBase).ToList() ?? new List<EntryContentBase>();

                var featuredProductList = productViewModels.Where(v => products.Any(p => p.ContentLink.ID == v.ProductId)).ToList();
                featuredProductList.ForEach(x => { x.IsFeaturedProduct = true; });

                productViewModels.RemoveAll(v => products.Any(p => p.ContentLink.ID == v.ProductId));
                productViewModels.InsertRange(0, featuredProductList);
            }

            var bestBetList = new BestBetRepository().List().Where(i => i.PhraseCriterion.Phrase.CompareTo(searchQuery) == 0);
            //Filter for product best bet only.
            var productBestBet  = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector);
            var ownStyleBestBet = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector && i.HasOwnStyle);

            productViewModels.ToList()
            .ForEach(p =>
            {
                if (productBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                {
                    p.IsBestBetProduct = true;
                }
                if (ownStyleBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                {
                    p.HasBestBetStyle = true;
                }
            });
        }
        /// <summary>
        /// Sets Featured Product property and Best Bet Product property to ProductViewModels.
        /// </summary>
        /// <param name="searchResult">The search result (product list).</param>
        /// <param name="currentContent">The product category.</param>
        /// <param name="searchQuery">The search query string to filter Best Bet result.</param>
        /// <param name="productViewModels">The ProductViewModels is added two properties: Featured Product and Best Bet.</param>
        private void ApplyBoostedProperties(ref List <ProductTileViewModel> productViewModels, IContentResult <EntryContentBase> searchResult, IContent currentContent, string searchQuery)
        {
            var node     = currentContent as GenericNode;
            var products = new List <EntryContentBase>();

            if (node != null)
            {
                UpdateListWithFeatured(ref productViewModels, node);
            }

            var bestBetList = new BestBetRepository().List().Where(i => i.PhraseCriterion.Phrase.CompareTo(searchQuery) == 0);
            //Filter for product best bet only.
            var productBestBet  = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector);
            var ownStyleBestBet = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector && i.HasOwnStyle);

            productViewModels.ToList()
            .ForEach(p =>
            {
                if (productBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                {
                    p.IsBestBetProduct = true;
                }
                if (ownStyleBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                {
                    p.HasBestBetStyle = true;
                }
            });
        }
Esempio n. 3
0
 public SearchService(ICurrentMarket currentMarket,
                      ICurrencyService currencyService,
                      LanguageResolver languageResolver,
                      IClient findClient,
                      IFacetRegistry facetRegistry,
                      IFindUIConfiguration findUIConfiguration,
                      ReferenceConverter referenceConverter,
                      IContentRepository contentRepository,
                      IPriceService priceService,
                      IPromotionService promotionService,
                      ICurrencyService currencyservice,
                      IContentLoader contentLoader,
                      BestBetRepository bestBetRepository
                      )
 {
     _currentMarket       = currentMarket;
     _currencyService     = currencyService;
     _languageResolver    = languageResolver;
     _findClient          = findClient;
     _facetRegistry       = facetRegistry;
     _findUIConfiguration = findUIConfiguration;
     //_findClient.Personalization().Refresh();
     _referenceConverter = referenceConverter;
     _contentRepository  = contentRepository;
     _priceService       = priceService;
     _promotionService   = promotionService;
     _currencyservice    = currencyservice;
     _contentLoader      = contentLoader;
     _bestBetRepository  = bestBetRepository;
 }
Esempio n. 4
0
        private CategoriesFilterViewModel GetCategoriesFilter(IContent currentContent, string query)
        {
            var bestBets         = new BestBetRepository().List().Where(i => i.PhraseCriterion.Phrase.CompareTo(query) == 0);
            var ownStyleBestBets = bestBets.Where(i => i.BestBetSelector is CommerceBestBetSelector && i.HasOwnStyle);
            var catalogId        = 0;
            var node             = currentContent as NodeContent;

            if (node != null)
            {
                catalogId = node.CatalogId;
            }
            var catalog = _contentLoader.GetChildren <CatalogContentBase>(_referenceConverter.GetRootLink())
                          .FirstOrDefault(x => catalogId == 0 || x.CatalogId == catalogId);

            if (catalog == null)
            {
                return(new CategoriesFilterViewModel());
            }

            var viewModel = new CategoriesFilterViewModel();
            var nodes     = _findClient.Search <NodeContent>()
                            .Filter(x => x.ParentLink.ID.Match(catalog.ContentLink.ID))
                            .FilterForVisitor()
                            .GetContentResult();

            foreach (var nodeContent in nodes)
            {
                var nodeFilter = new CategoryFilter
                {
                    DisplayName = nodeContent.DisplayName,
                    Url         = _urlResolver.GetUrl(nodeContent.ContentLink),
                    IsActive    = currentContent != null && currentContent.ContentLink == nodeContent.ContentLink,
                    IsBestBet   = ownStyleBestBets.Any(x => ((CommerceBestBetSelector)x.BestBetSelector).ContentLink.ID == nodeContent.ContentLink.ID)
                };
                viewModel.Categories.Add(nodeFilter);

                GetChildrenNode(currentContent, nodeContent, nodeFilter, ownStyleBestBets);
            }
            return(viewModel);
        }