예제 #1
0
        public static MetaInfo GetFormatedMetaInfo(MetaInfo meta, string name, string categoryName = null, string brandName = null, string price = null)
        {
            if (meta != null)
            {
                if (string.IsNullOrEmpty(meta.Title))
                {
                    meta.Title = SettingsSEO.GetDefaultTitle(meta.Type) ?? SettingsSEO.DefaultMetaTitle;
                }
                if (string.IsNullOrEmpty(meta.MetaKeywords))
                {
                    meta.MetaKeywords = SettingsSEO.GetDefaultMetaKeywords(meta.Type) ?? SettingsSEO.DefaultMetaKeywords;
                }
                if (string.IsNullOrEmpty(meta.MetaDescription))
                {
                    meta.MetaDescription = SettingsSEO.GetDefaultMetaDescription(meta.Type) ?? SettingsSEO.DefaultMetaKeywords;
                }
                if (string.IsNullOrEmpty(meta.H1))
                {
                    meta.H1 = SettingsSEO.GetDefaultH1(meta.Type) ?? SettingsSEO.DefaultH1;
                }

                meta.Title           = GlobalStringVariableService.TranslateExpression(meta.Title, meta.Type, name, categoryName, brandName, price);
                meta.MetaKeywords    = GlobalStringVariableService.TranslateExpression(meta.MetaKeywords, meta.Type, name, categoryName, brandName, price);
                meta.MetaDescription = GlobalStringVariableService.TranslateExpression(meta.MetaDescription, meta.Type, name, categoryName, brandName, price);
                meta.H1 = GlobalStringVariableService.TranslateExpression(meta.H1, meta.Type, name, categoryName, brandName, price);
            }
            return(meta);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ProductId == 0)
            {
                Error404();
                return;
            }

            //if not have category
            if (ProductService.GetCountOfCategoriesByProductId(ProductId) == 0)
            {
                Error404();
                return;
            }

            // --- Check product exist ------------------------
            CurrentProduct = ProductService.GetProduct(ProductId);

            if (CurrentProduct == null || CurrentProduct.Enabled == false || CurrentProduct.CategoryEnabled == false)
            {
                Error404();
                return;
            }

            btnAdd.Text            = SettingsCatalog.BuyButtonText;
            btnOrderByRequest.Text = SettingsCatalog.PreOrderButtonText;

            if (CurrentProduct.TotalAmount <= 0 || CurrentProduct.MainPrice == 0)
            {
                divAmount.Visible = false;
            }


            //CompareControl.ProductId = ProductId;

            CurrentOffer = OfferService.GetMainOffer(CurrentProduct.Offers, CurrentProduct.AllowPreOrder, Request["color"].TryParseInt(true), Request["size"].TryParseInt(true));

            if (CurrentOffer != null)
            {
                BuyInOneClick.OfferID = CurrentOffer.OfferId;

                sizeColorPicker.SelectedOfferId = CurrentOffer.OfferId;

                //CompareControl.Visible = divCompare.Visible = SettingsCatalog.EnableCompareProducts;
                //CompareControl.OfferId = CurrentOffer.OfferId;
                //CompareControl.IsSelected =
                //    ShoppingCartService.CurrentCompare.Any(p => p.Offer.OfferId == CurrentOffer.OfferId);

                //WishlistControl.OfferId = CurrentOffer.OfferId;
                //divWishlist.Visible = SettingsDesign.WishListVisibility;
            }
            else
            {
                //CompareControl.Visible = divCompare.Visible = false;
                //divWishlist.Visible = false;
                pnlPrice.Visible = false;
            }

            BuyInOneClick.ProductId       = CurrentProduct.ProductId;
            BuyInOneClick.SelectedOptions = productCustomOptions.SelectedOptions;
            BuyInOneClick.CustomOptions   = productCustomOptions.CustomOptions;

            sizeColorPicker.ProductId = ProductId;

            divUnit.Visible = (CustomerContext.CurrentCustomer.IsAdmin || AdvantShop.Trial.TrialService.IsTrialEnabled) && SettingsMain.EnableInplace ? true : CurrentProduct.Unit.IsNotEmpty();

            rating.ProductId  = CurrentProduct.ID;
            rating.Rating     = CurrentProduct.Ratio;
            rating.ShowRating = SettingsCatalog.EnableProductRating;
            rating.ReadOnly   = RatingService.DoesUserVote(ProductId, CustomerContext.CustomerId);

            pnlSize.Visible   = !string.IsNullOrEmpty(CurrentProduct.Size) && (CurrentProduct.Size != "0|0|0") && SettingsCatalog.DisplayDimensions;
            pnlWeight.Visible = CurrentProduct.Weight != 0 && SettingsCatalog.DisplayWeight;

            CurrentBrand     = CurrentProduct.Brand;
            pnlBrand.Visible = CurrentBrand != null && CurrentBrand.Enabled;
            //pnlBrnadLogo.Visible = CurrentBrand != null && CurrentBrand.Enabled && CurrentBrand.BrandLogo != null;

            productPropertiesView.ProductId      = ProductId;
            productBriefPropertiesView.ProductId = ProductId;

            productPhotoView.Product = CurrentProduct;

            ProductVideoView.ProductID = ProductId;
            relatedProducts.ProductIds.Add(ProductId);
            alternativeProducts.ProductIds.Add(ProductId);
            breadCrumbs.Items =
                CategoryService.GetParentCategories(CurrentProduct.CategoryId).Reverse().Select(cat => new BreadCrumbs
            {
                Name = cat.Name,
                Url  = UrlService.GetLink(ParamType.Category, cat.UrlPath, cat.ID)
            }).ToList();
            breadCrumbs.Items.Insert(0, new BreadCrumbs
            {
                Name = Resource.Client_MasterPage_MainPage,
                Url  = UrlService.GetAbsoluteLink("/")
            });

            breadCrumbs.Items.Add(new BreadCrumbs {
                Name = CurrentProduct.Name, Url = null
            });

            RecentlyViewService.SetRecentlyView(CustomerContext.CustomerId, ProductId);

            productReviews.EntityType = EntityType.Product;
            productReviews.EntityId   = ProductId;

            int reviewsCount = SettingsCatalog.ModerateReviews
                                   ? ReviewService.GetCheckedReviewsCount(ProductId, EntityType.Product)
                                   : ReviewService.GetReviewsCount(ProductId, EntityType.Product);

            if (reviewsCount > 0)
            {
                lReviewsCount.Text = string.Format("({0})", reviewsCount);
            }

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

            newMetaInfo                 = CurrentProduct.Meta;
            newMetaInfo.Title           = CurrentProduct.Name + " купить в интернет-магазине Корпорация Игрушек";
            newMetaInfo.MetaDescription = "Интернет-магазин Корпорация Игрушек представляет: " + CurrentProduct.Name + " и еще более 5,5 тысяч видов товаров по оптовым ценам. Порадуйте своего ребенка!";
            newMetaInfo.MetaKeywords    = CurrentProduct.Name;

            metaInfo = SetMeta(newMetaInfo, CurrentProduct.Name);

            //metaInfo = SetMeta(CurrentProduct.Meta, CurrentProduct.Name,
            //    CategoryService.GetCategory(CurrentProduct.CategoryId).Name,
            //    CurrentProduct.Brand != null ? CurrentProduct.Brand.Name : string.Empty,
            //    CatalogService.GetStringPrice(CurrentProduct.MainPrice -
            //                                  CurrentProduct.MainPrice * CurrentProduct.Discount / 100));

            if (SettingsSEO.ProductAdditionalDescription.IsNotEmpty())
            {
                liAdditionalDescription.Text =
                    GlobalStringVariableService.TranslateExpression(
                        SettingsSEO.ProductAdditionalDescription, MetaType.Product, CurrentProduct.Name,
                        CategoryService.GetCategory(CurrentProduct.CategoryId).Name,
                        CurrentProduct.Brand != null ? CurrentProduct.Brand.Name : string.Empty,
                        CatalogService.GetStringPrice(CurrentProduct.MainPrice -
                                                      CurrentProduct.MainPrice * CurrentProduct.Discount / 100));
            }

            LoadModules();

            if (GoogleTagManager.Enabled)
            {
                var tagManager = ((AdvantShopMasterPage)Master).TagManager;
                tagManager.PageType       = GoogleTagManager.ePageType.product;
                tagManager.ProdId         = CurrentOffer != null ? CurrentOffer.ArtNo : CurrentProduct.ArtNo;
                tagManager.ProdName       = CurrentProduct.Name;
                tagManager.ProdValue      = CurrentOffer != null ? CurrentOffer.Price : 0;
                tagManager.CatCurrentId   = CurrentProduct.MainCategory.ID;
                tagManager.CatCurrentName = CurrentProduct.MainCategory.Name;
            }
        }