public ActionResult _GetProductsForEndlessScrolling([DataSourceRequest] DataSourceRequest request,
                                                            int shopID, int?categoryID, int[] filtersArray = null, bool isBestSelling = false, string productName = "", bool refreshFilters = false,
                                                            bool favorite = false, bool allOrderedProducts = false, bool deals = false, string keywords = null)
        {
            bool firstBatch = request.Page == 1 ? true : false;

            if (request.PageSize == 0)
            {
                request.PageSize = 20;
            }
            var page = request.Page;
            List <SpecificationOptionModel> specifications = null;
            string tempString = null;
            List <ProductOverviewModel> list = new List <ProductOverviewModel>();

            if (favorite || allOrderedProducts || deals)
            {
                if (favorite)
                {
                    list.AddRange(LS.SearchProducts(shopID, out specifications, request.Page, request.PageSize, favorite: true, loadSpecifications: firstBatch, showDiscounts: true));
                }
                if (allOrderedProducts)
                {
                    list.AddRange(LS.SearchProducts(shopID, out specifications, request.Page, request.PageSize, allOrderedProducts: true, loadSpecifications: firstBatch, showDiscounts: true));
                }
                if (deals)
                {
                    //list.AddRange(LS.SearchProducts(shopID, out specifications, limit: int.MaxValue, discountedProducts: true, showDiscounts: true));
                    list.AddRange(LS.SearchProducts(shopID, out specifications, request.Page, request.PageSize, discountedProducts: true, showDiscounts: true));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(productName))
                {
                    bool FeautureTop = false;
                    if (!categoryID.HasValue &&
                        (filtersArray == null || filtersArray.Length == 0) &&
                        string.IsNullOrEmpty(keywords) &&
                        !isBestSelling
                        )
                    {
                        var sc = LS.Get <ShopCategoryMenu>().FirstOrDefault(x => x.ShopID == shopID && x.Published == true && x.Level == 0);


                        if (sc != null)
                        {
                            categoryID = sc.CategoryID;
                        }
                    }
                    list = LS.SearchProducts(shopID, out specifications, request.Page, request.PageSize, categoryID: categoryID, filters: filtersArray, loadSpecifications: firstBatch,
                                             favorite: favorite, allOrderedProducts: allOrderedProducts, featuredTop: FeautureTop, showDiscounts: true, keywords: keywords).ToList();
                }
                else
                {
                    list = LS.GetProductByName(shopID, productName).Skip(--page * request.PageSize).Take(request.PageSize).ToList(); //search by single name
                }
            }

            int total = request.PageSize * request.Page + 1;

            if (list.Count() < request.PageSize)
            {
                total = request.PageSize * (request.Page - 1) + list.Count();
            }
            var viewList = new List <JsonKeyValue>();

            foreach (var item in list)
            {
                viewList.Add(new JsonKeyValue()
                {
                    Name  = item.ProductShopID.ToString(),
                    Value = RenderPartialViewToString("_ProductGalleryItem", item),
                });
            }
            return(Json(new
            {
                Data = viewList,
                Total = total,
                Errors = tempString,
                AggregateResults = tempString,
            }));
        }