Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _paging = new SqlPaging();
            _paging.From("[Catalog].[Product]");
            _paging.Inner_Join("[Catalog].[ProductExt]  ON [Product].[ProductID] = [ProductExt].[ProductID]");
            _paging.Left_Join("[Catalog].[Photo]  ON [Photo].[PhotoId] = [ProductExt].[PhotoId]");
            _paging.Left_Join("[Catalog].[Offer] ON [ProductExt].[OfferID] = [Offer].[OfferID]");

            _paging.Left_Join("[Catalog].[ShoppingCart] ON [ShoppingCart].[OfferID] = [Offer].[OfferID] AND [ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = {0}", CustomerContext.CustomerId);
            _paging.Left_Join("[Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=[ShoppingCart].[CustomerID]");

            // Для сотрировки по популярности
            _paging.Left_Join(@"(Select [Order].[OrderItems].[ProductId], COUNT([Order].[OrderItems].[ProductId])as Popularity  From [Order].[OrderItems],[Catalog].[Product]
            where [Order].[OrderItems].[ProductId]=[Catalog].[Product].[ProductId]
            Group by  [Order].[OrderItems].[ProductId])as PopTable
            ON PopTable.ProductId=[Catalog].[Product].[ProductId]");

            _paging.Select(
                "[Product].[ProductID]",
                "CountPhoto",
                "Photo.PhotoId",
                "PhotoName AS Photo",
                "Photo.Description as PhotoDesc",
                "BriefDescription",
                "Product.ArtNo",
                "Name",
                "Recomended",
                "Bestseller",
                "New",
                "OnSale",
                "[Product].Discount",
                "Offer.OfferID",
                "MaxAvailable AS Amount",
                "MinAmount",
                "MaxAmount",
                "Enabled",
                "AllowPreOrder",
                "Ratio",
                "RatioID",
                "ShoppingCartItemId",
                "UrlPath",
                "Offer.ColorID",
                "null as AdditionalPhoto"
                );

            if (SettingsCatalog.ComplexFilter)
            {
                _paging.Select(
                    "Colors",
                    "NotSamePrices as MultiPrices",
                    "MinPrice as Price"
                    );
            }
            else
            {
                _paging.Select(
                    "null as Colors",
                    "0 as MultiPrices",
                    "Price"
                    );
            }

            BuildSorting();
            BuildFilter();

            var nmeta = new MetaInfo(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Client_Search_AdvancedSearch));

            SetMeta(nmeta, string.Empty, page: paging.CurrentPage);
            txtName.Focus();
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _paging = new SqlPaging();
            _paging.From("[Catalog].[Product]");
            _paging.Inner_Join("[Catalog].[ProductExt]  ON [Product].[ProductID] = [ProductExt].[ProductID]");
            _paging.Left_Join("[Catalog].[Photo]  ON [Photo].[PhotoId] = [ProductExt].[PhotoId]");
            _paging.Left_Join("[Catalog].[Offer] ON [ProductExt].[OfferID] = [Offer].[OfferID]");

            _paging.Left_Join("[Catalog].[ShoppingCart] ON [ShoppingCart].[OfferID] = [Offer].[OfferID] AND [ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = {0}", CustomerContext.CustomerId);
            _paging.Left_Join("[Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=[ShoppingCart].[CustomerID]");


            _paging.Select(
                "[Product].[ProductID]",
                "CountPhoto",
                "Photo.PhotoId",
                "PhotoName AS Photo",
                "Photo.Description as PhotoDesc",
                "BriefDescription",
                "Product.ArtNo",
                "Name",
                "Recomended",
                "Bestseller",
                "New",
                "OnSale",
                "[Product].Discount",
                "Offer.OfferID",
                "MaxAvailable AS Amount",
                "MinAmount",
                "MaxAmount",
                "Enabled",
                "AllowPreOrder",
                "Ratio",
                "RatioID",
                "ShoppingCartItemId",
                "UrlPath",
                "Offer.ColorID",
                "null as AdditionalPhoto"
                );

            if (SettingsCatalog.ComplexFilter)
            {
                _paging.Select(
                    "Colors",
                    "NotSamePrices as MultiPrices",
                    "MinPrice as Price"
                    );
            }
            else
            {
                _paging.Select(
                    "null as Colors",
                    "0 as MultiPrices",
                    "Price"
                    );
            }

            if (string.IsNullOrEmpty(Request["type"]) || !Enum.TryParse(Request["type"], true, out _typeFlag) ||
                _typeFlag == ProductOnMain.TypeFlag.None)
            {
                Error404();
            }

            switch (_typeFlag)
            {
            case ProductOnMain.TypeFlag.Bestseller:
                PageName = Resource.Client_ProductList_AllBestSellers;
                SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Bestsellers_Header), string.Empty);
                break;

            case ProductOnMain.TypeFlag.New:
                PageName = Resource.Client_ProductList_AllNew;
                SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_New_Header), string.Empty);
                break;

            case ProductOnMain.TypeFlag.Discount:
                PageName = Resource.Client_ProductList_AllDiscount;
                SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Discount_Header), string.Empty);
                break;

            case ProductOnMain.TypeFlag.OnSale:
                PageName = Resource.Client_ProductList_OnSale;
                SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_OnSale_Header), string.Empty);
                break;

            case ProductOnMain.TypeFlag.Recomended:
                PageName = Resource.Client_ProductList_Recomended;
                SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Recomended_Header), string.Empty);
                break;
            }

            ProductsCount       = ProductOnMain.GetProductCountByType(_typeFlag);
            pnlSort.Visible     = ProductsCount > 0;
            productView.Visible = ProductsCount > 0;

            breadCrumbs.Items.AddRange(new BreadCrumbs[]
            {
                new BreadCrumbs()
                {
                    Name = Resource.Client_MasterPage_MainPage,
                    Url  = UrlService.GetAbsoluteLink("/")
                },
                new BreadCrumbs()
                {
                    Name = PageName, Url = null
                }
            });

            BuildSorting();
            BuildFilter();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId))
            {
                Error404();
            }

            Category = CategoryService.GetCategory(_categoryId);
            if (Category == null || Category.Enabled == false || Category.ParentsEnabled == false)
            {
                Error404();
                return;
            }

            //Indepth = Request["indepth"] == "1" || Category.DisplayChildProducts;
            Indepth = true;

            _paging = new SqlPaging();
            _paging.From("[Catalog].[Product]");
            _paging.Left_Join("[Catalog].[ProductExt]  ON [Product].[ProductID] = [ProductExt].[ProductID]");
            _paging.Left_Join("[Catalog].[Photo]  ON [Photo].[PhotoId] = [ProductExt].[PhotoId]");
            _paging.Left_Join("[Catalog].[Offer] ON [ProductExt].[OfferID] = [Offer].[OfferID]");

            _paging.Left_Join("[Catalog].[ShoppingCart] ON [ShoppingCart].[OfferID] = [Offer].[OfferID] AND [ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = {0}", CustomerContext.CustomerId);
            _paging.Left_Join("[Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=[ShoppingCart].[CustomerID]");
            // Для сотрировки по популярности
            _paging.Left_Join(@"(Select [Order].[OrderItems].[ProductId], COUNT([Order].[OrderItems].[ProductId])as Popularity  From [Order].[OrderItems],[Catalog].[Product]
where [Order].[OrderItems].[ProductId]=[Catalog].[Product].[ProductId]
Group by  [Order].[OrderItems].[ProductId])as PopTable
ON PopTable.ProductId=[Catalog].[Product].[ProductId]");


            if (!Indepth)
            {
                _paging.Inner_Join("[Catalog].[ProductCategories] on [ProductCategories].[CategoryID] = {0} and  ProductCategories.ProductId = [Product].[ProductID]", _categoryId);
            }

            _paging.Select(
                "[Product].[ProductID]",
                "CountPhoto",
                "Photo.PhotoId",
                "PhotoName AS Photo",
                "Photo.Description as PhotoDesc",
                "BriefDescription",
                "Product.ArtNo",
                "Name",
                "Recomended",
                "Bestseller",
                "New",
                "OnSale",
                "[Product].Discount",
                "Offer.OfferID",
                "MaxAvailable AS Amount",
                "MinAmount",
                "MaxAmount",
                "Enabled",
                "AllowPreOrder",
                "Ratio",
                "RatioID",
                "ShoppingCartItemId",
                "UrlPath",
                "Offer.ColorID",
                "PopularityManually",
                "DateAdded",
                "ISNULL (Popularity , 0)as Popularity"
                );

            if (SettingsCatalog.ComplexFilter)
            {
                _paging.Select(
                    "Colors",
                    "NotSamePrices as MultiPrices",
                    "MinPrice as Price"
                    );
            }
            else
            {
                _paging.Select(
                    "null as Colors",
                    "0 as MultiPrices",
                    "Price"
                    );
            }

            ProductsCount = Indepth ? Category.ProductsCount : CategoryService.GetEnabledProductsCountInCategory(Category.ID, Indepth);

            categoryView.CategoryID = _categoryId;
            //categoryView.Visible = Category.DisplayStyle == "True" || ProductsCount == 0;
            categoryView.Visible = false;

            pnlSort.Visible        = ProductsCount > 0;
            productView.Visible    = ProductsCount > 0;
            catalogView.CategoryID = _categoryId;

            filterProperty.CategoryId = _categoryId;

            filterBrand.CategoryId = _categoryId;
            filterBrand.InDepth    = Indepth;
            filterBrand.Visible    = SettingsCatalog.ShowProducerFilter;

            filterSize.CategoryId = _categoryId;
            filterSize.InDepth    = Indepth;
            filterSize.Visible    = SettingsCatalog.ShowSizeFilter;

            filterColor.CategoryId = _categoryId;
            filterColor.InDepth    = Indepth;
            filterColor.Visible    = SettingsCatalog.ShowColorFilter;

            filterPrice.CategoryId = _categoryId;
            filterPrice.InDepth    = Indepth;
            filterPrice.Visible    = SettingsCatalog.ShowPriceFilter;


            lblCategoryName.Text = _categoryId != 0 ? Category.Meta.H1 : Resource.Client_MasterPage_Catalog;

            breadCrumbs.Items =
                CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs
            {
                Name = parent.Name,
                Url  = UrlService.GetLink(ParamType.Category, parent.UrlPath, parent.CategoryId)
            }).Reverse().ToList();

            if (_categoryId == 0)
            {
                breadCrumbs.Items.Add(new BreadCrumbs
                {
                    Name = Resource.Client_MasterPage_Catalog,
                    Url  = UrlService.GetAbsoluteLink("catalog")
                });
            }

            breadCrumbs.Items.Insert(0, new BreadCrumbs
            {
                Name = Resource.Client_MasterPage_MainPage,
                Url  = UrlService.GetAbsoluteLink("/")
            });

            //Добавим новые meta
            MetaInfo newMetaInfo = new MetaInfo();

            newMetaInfo = Category.Meta;

            StringBuilder newTitle     = new StringBuilder("", 200);
            string        polTitle     = "";
            string        vozrastTitle = "";
            string        brandTitle   = "";

            //если в фильтре указан бренд
            if (!string.IsNullOrEmpty(Request["brand"]))
            {
                brandTitle = BrandService.GetBrandById(int.Parse(Request["brand"])).Name;
            }

            // если в фильтре выбраны пол (prop = 5083 для девочек, prop = 5084 для мальчиков) или
            //возраст( prop = 5087   0 - 12 мес, prop = 5086   1 - 3 года, prop = 5075   4 - 5 лет, prop = 5081  6 - 8 лет, prop = 5082  9 - 11 лет, prop = 5085  более 12 лет
            if (!string.IsNullOrEmpty(Request["prop"]))
            {
                var filterCol = Request["prop"].Split('-');
                foreach (var val in filterCol)
                {
                    switch (val)
                    {
                    case "5083":
                        polTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5084":
                        polTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5087":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5086":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5075":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5081":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5082":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;

                    case "5085":
                        vozrastTitle = PropertyService.GetPropertyValueById(int.Parse(val)).Value;
                        break;
                    }
                }
            }

            //если  пол или возраст указаны в фильтре
            if (polTitle != "" || vozrastTitle != "")
            {
                newTitle.Append("Игрушки ");
                if (polTitle != "")
                {
                    newTitle.Append(polTitle);
                }
                if (vozrastTitle != "")
                {
                    newTitle.Append((newTitle.ToString() == "") ? vozrastTitle : ", " + vozrastTitle);
                }
                if (brandTitle != "")
                {
                    newTitle.Append(" от " + brandTitle);
                }
            }
            //если пол и возраст не указаны в фильтре
            else
            {
                newTitle.Append(Category.Name);
                if (brandTitle != "")
                {
                    newTitle.Append(" " + brandTitle);
                }
            }
            newMetaInfo.Title           = newTitle + " купить в интернет-магазине Корпорация Игрушек";
            newMetaInfo.MetaDescription = "Интернет-магазин Корпорация Игрушек представляет: " + newTitle.ToString() + " и еще более 5,5 тысяч видов товаров по оптовым ценам. Порадуйте своего ребенка!";
            newMetaInfo.MetaKeywords    = (polTitle != "" || vozrastTitle != "") ? "Игрушки " + newTitle.ToString() : newTitle.ToString();

            var metaInfo = SetMeta(newMetaInfo, Category.Name, page: paging.CurrentPage);

            //var metaInfo = SetMeta(Category.Meta, Category.Name, page: paging.CurrentPage);
            lblCategoryName.Text = metaInfo.H1;

            BuildSorting();
            BuildFilter();
        }