Example #1
0
        /// <summary>
        /// search categories by given criteria
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public IPagedList <Category> SearchCategories(CatalogSearchCriteria criteria)
        {
            var workContext = _workContextFactory();

            criteria = criteria.Clone();
            //exclude products
            criteria.ResponseGroup = criteria.ResponseGroup & (~CatalogSearchResponseGroup.WithProducts);
            //include categories
            criteria.ResponseGroup = criteria.ResponseGroup | CatalogSearchResponseGroup.WithCategories;
            var searchCriteria = criteria.ToServiceModel(workContext);
            var categories     = _catalogModuleApi.CatalogModuleSearchSearch(searchCriteria).Categories.Select(x => x.ToWebModel(workContext.CurrentLanguage, workContext.CurrentStore)).ToList();

            //API temporary does not support paginating request to categories (that's uses PagedList with superset)
            return(new PagedList <Category>(categories, criteria.PageNumber, criteria.PageSize));
        }