/// <summary>
        /// Binds the filters.
        /// </summary>
        private void BindFilters()
        {
            if (Filters != null && Filters.Length > 0)
            {
                ActiveFilterList.DataSource = Filters;
                ActiveFilterList.DataBind();
                ActiveFilterList.Visible = true;
            }
            else
            {
                ActiveFilterList.Visible = false;
            }

            if (Facets != null && Facets.Length > 0)
            {
                FilterList.Visible    = true;
                FilterList.DataSource = Facets;
                FilterList.DataBind();
            }
            else
            {
                FilterList.Visible = false;
            }
        }
Exemple #2
0
        /// <summary>
        /// Binds the results.
        /// </summary>
        private void BindResults(bool list)
        {
            SearchSort sortObject = CatalogEntrySearchCriteria.DefaultSortOrder;
            //string sort = SortBy.SelectedValue;
            //if (!String.IsNullOrEmpty(sort))
            //{
            //    if (sort.Equals("name", StringComparison.OrdinalIgnoreCase))
            //        sortObject = new SearchSort("displayname");
            //    else if (sort.Equals("plh", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower());
            //    else if (sort.Equals("phl", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower(), true);
            //}

            var group = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            SearchFilterHelper         helper   = SearchFilterHelper.Current;
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteria("", sortObject);

            //AddNodesToCriteria(criteria);
            criteria.RecordsToRetrieve = 25;
            criteria.StartingRecord    = _startRowIndex;
            criteria.ClassTypes.Add("Product");

            var searchManager = new SearchManager(AppContext.Current.ApplicationName);

            try
            {
                var results = searchManager.Search(criteria);
                if (results == null)
                {
                    return;
                }

                var resultIndexes = results.GetKeyFieldValues <int>();
                var entries       = CatalogContext.Current.GetCatalogEntries(resultIndexes, group);
                if (entries.Entry != null)
                {
                    var ds = CreateDataSource(entries, results.TotalCount);
                    if (!list)
                    {
                        EntriesList.DataSource = ds;
                        EntriesList.DataBind();
                        EntriesList.Visible = true;
                        listView.Visible    = false;
                    }
                    else
                    {
                        listView.DataSource = ds;
                        listView.DataBind();
                        EntriesList.Visible = false;
                        listView.Visible    = true;
                    }

                    if (results.TotalCount < 25)
                    {
                        DataPager3.Visible = false;
                    }
                }

                _filters = helper.SelectedFilters;
                _facets  = results.FacetGroups;

                if (_filters != null && _filters.Length > 0)
                {
                    ActiveFilterList.DataSource = _filters;
                    ActiveFilterList.DataBind();
                    ActiveFilterList.Visible = true;
                }
                else
                {
                    ActiveFilterList.Visible = false;
                }

                if (_facets != null && _facets.Length > 0)
                {
                    FilterList.Visible    = true;
                    FilterList.DataSource = _facets;
                    FilterList.DataBind();
                }
                else
                {
                    FilterList.Visible = false;
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(GetType()).Error(ex.Message, ex);
            }
        }