protected void BindProductInfo(Product product) { lProductName.Text = Server.HtmlEncode(product.Name); // lProductName1.Text = Server.HtmlEncode(product.Name); lShortDescription.Text = product.ShortDescription; lFullDescription.Text = product.FullDescription; var productPictures = product.ProductPictures; if (productPictures.Count > 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.DataSource = productPictures; lvProductPictures.DataBind(); } else if (productPictures.Count == 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } else { defaultImage.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } }
public string GetProductVariantImageUrl(ShoppingCartItem shoppingCartItem) { string pictureUrl = String.Empty; var productVariant = shoppingCartItem.ProductVariant; if (productVariant != null) { var productVariantPicture = productVariant.Picture; pictureUrl = PictureManager.GetPictureUrl(productVariantPicture, SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80), false); if (String.IsNullOrEmpty(pictureUrl)) { var product = productVariant.Product; ProductPicture productPicture = product.DefaultProductPicture; if (productPicture != null) { pictureUrl = PictureManager.GetPictureUrl(productPicture.Picture, SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80)); } else { pictureUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80)); } } } return(pictureUrl); }
protected void dlSubCategories_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var category = e.Item.DataItem as Category; string categoryURL = SEOHelper.GetCategoryUrl(category.CategoryId); var hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink; if (hlImageLink != null) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(category.PictureId, SettingManager.GetSettingValueInteger("Media.Category.ThumbnailImageSize", 125), true); hlImageLink.NavigateUrl = categoryURL; hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Category.ImageAlternateTextFormat"), category.Name); } var hlCategory = e.Item.FindControl("hlCategory") as HyperLink; if (hlCategory != null) { hlCategory.NavigateUrl = categoryURL; hlCategory.ToolTip = String.Format(GetLocaleResourceString("Media.Category.ImageLinkTitleFormat"), category.Name); hlCategory.Text = Server.HtmlEncode(category.Name); } } }
private void BindData() { var manufacturer = ManufacturerManager.GetManufacturerById(this.ManufacturerId, 0); if (this.HasLocalizableContent) { var languages = this.GetLocalizableLanguagesSupported(); rptrLanguageTabs.DataSource = languages; rptrLanguageTabs.DataBind(); rptrLanguageDivs.DataSource = languages; rptrLanguageDivs.DataBind(); } if (manufacturer != null) { this.txtName.Text = manufacturer.Name; this.txtDescription.Content = manufacturer.Description; CommonHelper.SelectListItem(this.ddlTemplate, manufacturer.TemplateId); var manufacturerPicture = manufacturer.Picture; btnRemoveManufacturerImage.Visible = manufacturerPicture != null; string pictureUrl = PictureManager.GetPictureUrl(manufacturerPicture, 100); this.iManufacturerPicture.Visible = true; this.iManufacturerPicture.ImageUrl = pictureUrl; this.txtPriceRanges.Text = manufacturer.PriceRanges; this.cbPublished.Checked = manufacturer.Published; this.txtDisplayOrder.Value = manufacturer.DisplayOrder; } else { this.btnRemoveManufacturerImage.Visible = false; this.iManufacturerPicture.Visible = false; } }
protected void dlAlsoPurchasedProducts_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var product = e.Item.DataItem as Product; if (product != null) { string productURL = SEOHelper.GetProductUrl(product); var hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink; if (hlImageLink != null) { ProductPicture productPicture = product.DefaultProductPicture; if (productPicture != null) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPicture.Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125)); } hlImageLink.NavigateUrl = productURL; hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } var hlProduct = e.Item.FindControl("hlProduct") as HyperLink; if (hlProduct != null) { hlProduct.NavigateUrl = productURL; hlProduct.Text = product.Name; } } } }
protected void rptVariants_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ProductVariant productVariant = e.Item.DataItem as ProductVariant; Panel pnlDownloadSample = e.Item.FindControl("pnlDownloadSample") as Panel; HyperLink hlDownloadSample = e.Item.FindControl("hlDownloadSample") as HyperLink; Image iProductVariantPicture = e.Item.FindControl("iProductVariantPicture") as Image; NumericTextBox txtQuantity = e.Item.FindControl("txtQuantity") as NumericTextBox; Button btnAddToCart = e.Item.FindControl("btnAddToCart") as Button; Button btnAddToWishlist = e.Item.FindControl("btnAddToWishlist") as Button; if (iProductVariantPicture != null) { Picture productVariantPicture = productVariant.Picture; string pictureUrl = PictureManager.GetPictureUrl(productVariantPicture, SettingManager.GetSettingValueInteger("Media.Product.VariantImageSize", 125), false); if (String.IsNullOrEmpty(pictureUrl)) { iProductVariantPicture.Visible = false; } else { iProductVariantPicture.ImageUrl = pictureUrl; } iProductVariantPicture.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), productVariant.Name); iProductVariantPicture.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), productVariant.Name); } btnAddToWishlist.Visible = SettingManager.GetSettingValueBoolean("Common.EnableWishlist"); if (!productVariant.DisableBuyButton) { txtQuantity.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantID); btnAddToCart.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantID); btnAddToWishlist.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantID); txtQuantity.Value = productVariant.OrderMinimumQuantity; } else { txtQuantity.Visible = false; btnAddToCart.Visible = false; btnAddToWishlist.Visible = false; } if (pnlDownloadSample != null && hlDownloadSample != null) { if (productVariant.IsDownload && productVariant.HasSampleDownload) { pnlDownloadSample.Visible = true; hlDownloadSample.NavigateUrl = DownloadManager.GetSampleDownloadUrl(productVariant); } else { pnlDownloadSample.Visible = false; } } } }
protected void cmdGenerateNewSize_Click(object sender, EventArgs e) { int width = txtNewPictureSize.Value; if (width > 10 && PictureID > 0) { PictureManager.GetPictureUrl(PictureID, width); BindSizeRepeater(PictureID); } }
private void BindData() { if (product != null) { string productURL = SEOHelper.GetProductUrl(product); hlProduct.NavigateUrl = productURL; hlProduct.Text = Server.HtmlEncode(product.LocalizedName); var picture = product.DefaultPicture; if (picture != null) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(picture, this.ProductImageSize, true); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.LocalizedName); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.LocalizedName); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName); } hlImageLink.NavigateUrl = productURL; lShortDescription.Text = product.LocalizedShortDescription; var productVariantCollection = product.ProductVariants; if (productVariantCollection.Count > 0) { if (!product.HasMultipleVariants) { var productVariant = productVariantCollection[0]; btnAddToCart.Visible = (!productVariant.DisableBuyButton); if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { //nothing } else { btnAddToCart.Visible = false; } } else { btnAddToCart.Visible = false; } } else { btnAddToCart.Visible = false; } } }
protected void gvPictures_RowDataBound(object sender, GridViewRowEventArgs e) { Picture picture = (Picture)e.Row.DataItem; if (picture != null) { Image imagePicture = e.Row.FindControl("imagePicture") as Image; if (imagePicture != null) { imagePicture.ImageUrl = PictureManager.GetPictureUrl(picture, 100); } } }
public string GetProductImageUrl(Product product) { var picture = product.DefaultPicture; if (picture != null) { return(PictureManager.GetPictureUrl(picture, SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80))); } else { return(PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.ShoppingCart.ThumbnailImageSize", 80))); } }
protected void gvwImages_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ProductPicture productPicture = (ProductPicture)e.Row.DataItem; Image iProductPicture = e.Row.FindControl("iProductPicture") as Image; if (iProductPicture != null) { iProductPicture.ImageUrl = PictureManager.GetPictureUrl(productPicture.PictureID); } Button btnUpdate = e.Row.FindControl("btnUpdate") as Button; if (btnUpdate != null) { btnUpdate.CommandArgument = e.Row.RowIndex.ToString(); } } }
private void BindData() { Product product = ProductManager.GetProductById(ProductId); if (product != null) { pnlData.Visible = true; pnlMessage.Visible = false; CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(this.ProductId); if (catalog != null) { if (catalog.lwg_Audio.Count > 0) { gvAudios.Visible = true; gvAudios.DataSource = catalog.lwg_Audio; gvAudios.DataBind(); } else { gvAudios.Visible = false; } if (!string.IsNullOrEmpty(catalog.SoundIcon)) { int temp = 0; if (int.TryParse(catalog.SoundIcon, out temp) && temp > 0) { Picture Picture = PictureManager.GetPictureById(temp); string pictureUrl = PictureManager.GetPictureUrl(Picture, 100); imgSoundIcon.Visible = true; imgSoundIcon.ImageUrl = pictureUrl; } } } } else { pnlData.Visible = false; pnlMessage.Visible = true; } }
private void BindData() { pnlCustomerAvatarError.Visible = false; var customerAvatar = NopContext.Current.User.Avatar; int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); string pictureUrl = string.Empty; if (customerAvatar != null) { pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false); this.btnRemoveAvatar.Visible = true; } else { pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.btnRemoveAvatar.Visible = false; } this.iAvatar.ImageUrl = pictureUrl; }
protected void dlCatalog_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { BestSellersReportLine bestSellersReportLine = e.Item.DataItem as BestSellersReportLine; ProductVariant productVariant = ProductManager.GetProductVariantByID(bestSellersReportLine.ProductVariantID); if (productVariant != null) { Product product = productVariant.Product; if (product != null) { string productURL = SEOHelper.GetProductURL(product); HyperLink hlImageLink = e.Item.FindControl("hlImageLink") as HyperLink; if (hlImageLink != null) { ProductPictureCollection productPictures = product.ProductPictures; if (productPictures.Count > 0) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125)); } hlImageLink.NavigateUrl = productURL; hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } HyperLink hlProduct = e.Item.FindControl("hlProduct") as HyperLink; if (hlProduct != null) { hlProduct.NavigateUrl = productURL; hlProduct.Text = Server.HtmlEncode(product.Name); } } } } }
private void BindData() { Category category = CategoryManager.GetCategoryById(this.CategoryId); if (this.HasLocalizableContent) { var languages = this.GetLocalizableLanguagesSupported(); rptrLanguageTabs.DataSource = languages; rptrLanguageTabs.DataBind(); rptrLanguageDivs.DataSource = languages; rptrLanguageDivs.DataBind(); } if (category != null) { this.txtName.Text = category.Name; this.txtDescription.Content = category.Description; CommonHelper.SelectListItem(this.ddlTemplate, category.TemplateId); ParentCategory.SelectedCategoryId = category.ParentCategoryId; Picture categoryPicture = category.Picture; this.btnRemoveCategoryImage.Visible = categoryPicture != null; string pictureUrl = PictureManager.GetPictureUrl(categoryPicture, 100); this.iCategoryPicture.Visible = true; this.iCategoryPicture.ImageUrl = pictureUrl; this.txtPriceRanges.Text = category.PriceRanges; this.cbShowOnHomePage.Checked = category.ShowOnHomePage; this.cbPublished.Checked = category.Published; this.txtDisplayOrder.Value = category.DisplayOrder; this.ParentCategory.BindData(); } else { this.btnRemoveCategoryImage.Visible = false; this.iCategoryPicture.Visible = false; ParentCategory.SelectedCategoryId = this.ParentCategoryId; ParentCategory.BindData(); } }
protected override void Render(HtmlTextWriter writer) { if (Level == 0) { if (ParentId <= MaxCount) { writer.WriteLine("<div class=\"item\">"); string navigateUrl = ChildCategoryUrl; if (String.IsNullOrEmpty(navigateUrl)) { navigateUrl = "javascript:void(0);"; } writer.WriteLine(string.Format("<a href=\"{0}\" onclick=\"show_div('div_{1}')\" title=\"{2}\">", navigateUrl, ParentId - 1, Title)); string url = Picture != null ? PictureManager.GetPictureUrl(Picture.PictureID, 35) : Page.ResolveUrl("~/images/ff_images/submenu/subitem.jpg"); writer.WriteLine(string.Format("<img src=\"" + url + "\" alt=\"\" />{0}</a></div>", Title)); } } else if (Level == 1) { if (Id == 1) { writer.WriteLine(string.Format("<div id=\"div_{0}\" class=\"div_1\" style=\"display: none;\">", ParentId - 1)); } writer.WriteLine(string.Format("<img src=\"" + Page.ResolveUrl("~/images/ff_images/submenu/subitem.jpg") + "\" alt=\"\" />")); writer.WriteLine(string.Format("<a href=\"{0}\" title=\"{1}\">{1}</a>", NavigateUrl, Title)); if (Id < TotalMenuItems) { writer.WriteLine("<br />"); } else { writer.WriteLine("</div>"); } } }
private void BindData() { if (product != null) { string productURL = SEOHelper.GetProductURL(product); ProductPictureCollection productPictures = product.ProductPictures; if (productPictures.Count > 0) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, ProductImageSize, true); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } hlImageLink.NavigateUrl = productURL; } }
private void BindData() { Customer customer = CustomerManager.GetCustomerById(this.CustomerId); if (customer != null) { var customerAvatar = customer.Avatar; int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); string pictureUrl = string.Empty; if (customerAvatar != null) { pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false); this.btnRemoveAvatar.Visible = true; } else { pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.btnRemoveAvatar.Visible = false; } this.imgAvatar.ImageUrl = pictureUrl; } }
protected virtual void GetPictureUrls <T>(T model) where T : class { if (model == null) { return; } var type = typeof(T); var specialProperties = type.GetRuntimeProperties() .Where(pi => pi.PropertyType == typeof(string) && pi.GetCustomAttributes <PictureUrlAttribute>(true).Any()) .ToList(); if (!specialProperties.HasData()) { return; } foreach (var specialProperty in specialProperties) { var pInfo = typeof(T).GetProperty(specialProperty.Name) .GetCustomAttribute <PictureUrlAttribute>(); var idProperty = pInfo.From.IsNotNullOrEmpty() ? typeof(T).GetProperty(pInfo.From) : null; int size = pInfo.Size; if (idProperty != null) { var idPropertyValue = idProperty.GetValue(model); if (idPropertyValue != null) { if (idProperty.PropertyType == typeof(int)) { specialProperty.SetValue(model, PictureManager.GetPictureUrl((int)idPropertyValue, size)); } else { specialProperty.SetValue(model, PictureManager.GetPictureUrls((string)idPropertyValue, size)); } } } } }
private string SavePictureIcon(FileUpload fileupload) { Picture pic = null; lwg_Catalog lwg = new CatalogBiz().GetByID(ProductId); if (lwg != null) { if (!string.IsNullOrEmpty(lwg.SoundIcon)) { pic = PictureManager.GetPictureById(int.Parse(lwg.SoundIcon)); } } HttpPostedFile PictureFile = fileupload.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] pictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); if (pic != null) { pic = PictureManager.UpdatePicture(pic.PictureId, pictureBinary, PictureFile.ContentType, true); } else { pic = PictureManager.InsertPicture(pictureBinary, PictureFile.ContentType, true); } } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; //\ string pictureUrl = PictureManager.GetPictureUrl(pic, 100); imgSoundIcon.Visible = true; imgSoundIcon.ImageUrl = pictureUrl; } return(PictureId.ToString()); }
public void BindData() { if (blogComment != null) { lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(blogComment.CreatedOn).ToString("g"); lblComment.Text = BlogManager.FormatCommentText(blogComment.CommentText); lblBlogCommentId.Text = blogComment.BlogCommentId.ToString(); var customer = blogComment.Customer; if (customer != null) { if (CustomerManager.AllowViewingProfiles) { hlUser.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer)); hlUser.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId); lblUser.Visible = false; } else { lblUser.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer)); hlUser.Visible = false; } if (CustomerManager.AllowCustomersToUploadAvatars) { var customerAvatar = customer.Avatar; int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); if (customerAvatar != null) { string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false); this.imgAvatar.ImageUrl = pictureUrl; } else { if (CustomerManager.DefaultAvatarEnabled) { string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.imgAvatar.ImageUrl = pictureUrl; } else { imgAvatar.Visible = false; } } } else { imgAvatar.Visible = false; } } else { lblUser.Text = GetLocaleResourceString("Customer.NotRegistered"); hlUser.Visible = false; if (CustomerManager.AllowCustomersToUploadAvatars && CustomerManager.DefaultAvatarEnabled) { int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.imgAvatar.ImageUrl = pictureUrl; } else { imgAvatar.Visible = false; } } } }
private void BindData() { var customer = CustomerManager.GetCustomerById(this.CustomerId); if (customer == null) { this.Visible = false; return; } if (CustomerManager.AllowCustomersToUploadAvatars) { phAvatar.Visible = true; var customerAvatar = customer.Avatar; int avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85); if (customerAvatar != null) { string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false); this.imgAvatar.ImageUrl = pictureUrl; } else { if (CustomerManager.DefaultAvatarEnabled) { string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize); this.imgAvatar.ImageUrl = pictureUrl; } else { phAvatar.Visible = false; } } } else { phAvatar.Visible = false; } phFullName.Visible = false; if (CustomerManager.ShowCustomersLocation) { phLocation.Visible = true; var country = CountryManager.GetCountryById(customer.CountryId); if (country != null) { lblCountry.Text = Server.HtmlEncode(country.Name); } else { phLocation.Visible = false; } } else { phLocation.Visible = false; } if (ForumManager.AllowPrivateMessages) { if (customer != null && !customer.IsGuest) { btnSendPM.CustomerId = customer.CustomerId; phPM.Visible = true; } else { phPM.Visible = false; } } else { phPM.Visible = false; } if (ForumManager.ForumsEnabled && ForumManager.ShowCustomersPostCount) { phTotalPosts.Visible = true; lblTotalPosts.Text = customer.TotalForumPosts.ToString(); } else { phTotalPosts.Visible = false; } if (CustomerManager.ShowCustomersJoinDate) { phJoinDate.Visible = true; lblJoinDate.Text = DateTimeHelper.ConvertToUserTime(customer.RegistrationDate).ToString("f"); } else { phJoinDate.Visible = false; } if (customer.DateOfBirth.HasValue) { lblDateOfBirth.Text = customer.DateOfBirth.Value.ToString("D"); } else { phDateOfBirth.Visible = false; } if (ForumManager.ForumsEnabled) { int totaRecords = 0; int pageSize = 5; if (ForumManager.LatestUserPostsPageSize > 0) { pageSize = ForumManager.LatestUserPostsPageSize; } var forumPosts = ForumManager.GetAllPosts(0, customer.CustomerId, string.Empty, false, pageSize, 0, out totaRecords); if (forumPosts.Count > 0) { rptrLatestPosts.DataSource = forumPosts; rptrLatestPosts.DataBind(); } else { phLatestPosts.Visible = false; } } else { phLatestPosts.Visible = false; } }
/// <summary> /// Generate froogle feed /// </summary> /// <param name="stream">Stream</param> public static void GenerateFeed(Stream stream) { const string googleBaseNamespace = "http://base.google.com/ns/1.0"; var settings = new XmlWriterSettings { Encoding = Encoding.UTF8 }; using (var writer = XmlWriter.Create(stream, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("rss"); writer.WriteAttributeString("version", "2.0"); writer.WriteAttributeString("xmlns", "g", null, googleBaseNamespace); writer.WriteStartElement("channel"); writer.WriteElementString("title", string.Format("{0} Google Base", SettingManager.StoreName)); writer.WriteElementString("link", "http://base.google.com/base/"); writer.WriteElementString("description", "Information about products"); var products = ProductManager.GetAllProducts(false); foreach (var product in products) { var productVariants = ProductManager.GetProductVariantsByProductId(product.ProductId, false); foreach (var productVariant in productVariants) { writer.WriteStartElement("item"); writer.WriteElementString("link", SEOHelper.GetProductUrl(product)); writer.WriteElementString("title", productVariant.FullProductName); writer.WriteStartElement("description"); string description = productVariant.Description; if (String.IsNullOrEmpty(description)) { description = product.FullDescription; } if (String.IsNullOrEmpty(description)) { description = product.ShortDescription; } if (String.IsNullOrEmpty(description)) { description = product.Name; } writer.WriteCData(description); writer.WriteEndElement(); // description writer.WriteStartElement("g", "brand", googleBaseNamespace); writer.WriteFullEndElement(); // g:brand writer.WriteElementString("g", "condition", googleBaseNamespace, "new"); writer.WriteElementString("g", "expiration_date", googleBaseNamespace, DateTime.Now.AddDays(28).ToString("yyyy-MM-dd")); writer.WriteElementString("g", "id", googleBaseNamespace, productVariant.ProductVariantId.ToString()); string imageUrl = string.Empty; var pictures = PictureManager.GetPicturesByProductId(product.ProductId, 1); if (pictures.Count > 0) { imageUrl = PictureManager.GetPictureUrl(pictures[0], SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize"), true); } writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl); decimal price = productVariant.Price; writer.WriteElementString("g", "price", googleBaseNamespace, price.ToString(new CultureInfo("en-US", false).NumberFormat)); //uncomment and set your product_type attribute //writer.WriteStartElement("g", "product_type", googleBaseNamespace); //writer.WriteCData("Clothing & Accessories > Clothing Accessories > Hair Accessories > Hair Pins & Clips"); //writer.WriteFullEndElement(); // g:brand //if (productVariant.Weight != decimal.Zero) //{ // writer.WriteElementString("g", "weight", googleBaseNamespace, string.Format(CultureInfo.InvariantCulture, "{0} {1}", productVariant.Weight.ToString(new CultureInfo("en-US", false).NumberFormat), MeasureManager.BaseWeightIn.SystemKeyword)); //} writer.WriteEndElement(); // item } } writer.WriteEndElement(); // channel writer.WriteEndElement(); // rss writer.WriteEndDocument(); } }
protected void BindData() { var product = ProductManager.GetProductById(this.ProductId); if (product != null) { ctrlProductRating.Visible = product.AllowCustomerRatings; //Get product extend information CatalogBiz cService = new CatalogBiz(); lwg_Catalog catalog = cService.GetByID(product.ProductId); lProductName.Text = Server.HtmlEncode(product.Name); lProductName1.Text = Server.HtmlEncode(product.Name); lShortDescription.Text = product.ShortDescription; lFullDescription.Text = product.FullDescription; lTableofContents.Text = catalog.TableofContents; ltrSubtitle.Text = catalog.Subtitle; var productPictures = product.ProductPictures; if (productPictures.Count > 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.DataSource = productPictures; lvProductPictures.DataBind(); } else if (productPictures.Count == 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } else { defaultImage.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } if (catalog != null) { lProductName.Text = catalog.CatalogNumber + " - " + lProductName.Text; //lProductName1.Text = catalog.TitleDisplay; string strCompare = "http://"; AudioBiz audioBiz = new AudioBiz(); //lwg_Audio audio = audioBiz.GetSoundFile(catalog.CatalogId); //if (audio != null) //{ // if (audio.SoundFile.TrimStart().StartsWith(strCompare)) // { // hplListenToTheSample.NavigateUrl = audio.SoundFile; // } // else // { // hplListenToTheSample.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile); // } //} List <lwg_Audio> audioList = audioBiz.GetAllSoundFiles(catalog.CatalogId); if (audioList.Count > 0) { dlListenMusics.DataSource = audioList; dlListenMusics.DataBind(); divListenToTheSample.Attributes.Add("style", "display:block;"); } if (!string.IsNullOrEmpty(catalog.PDF)) { hplPreviewMusic.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetPDFPath(), catalog.PDF); divPreviewMusic.Attributes.Add("style", "display:block;"); } if (catalog.lwg_PersonInRole != null && catalog.lwg_PersonInRole.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (lwg_PersonInRole catComposer in catalog.lwg_PersonInRole.OrderBy(p => p.RoleId)) { if (catComposer.RoleId == LWGUtils.COMPOSER_ROLE_ID) { sb.Insert(0, string.Format("{0} ({1}), ", catComposer.lwg_Person.NameDisplay, catComposer.lwg_Role.Name)); } else { sb.Append(catComposer.lwg_Person.NameDisplay).Append(" (" + catComposer.lwg_Role.Name).Append("), "); } } string composer = sb.ToString(); if (composer.Length > 0) { try { composer = composer.Substring(0, composer.Length - 2); } catch { ; } } ltrComposer.Text = "by " + composer; } else { ltrComposer.Text = string.Empty; } if (product.ProductVariants.Count > 0) { this.ltrPrice.Text = string.Format("{0:c}", product.ProductVariants[0].Price); productVariantRepeater.DataSource = product.ProductVariants.OrderBy(pv => pv.Price); productVariantRepeater.DataBind(); } else { this.ltrPrice.Text = string.Format("{0:c}", "0"); } this.ltrDuration.Text = catalog.Duration; if (catalog.lwg_Instrumental != null) { this.ltrInstrumention.Text = catalog.lwg_Instrumental.LongName; } this.ltrYear.Text = catalog.Year; this.ltrPeriod.Text = string.Empty; List <lwg_PeriodMapping> lstPeriod = new PeriodBiz().GetListPeriodMappingByCatalogID(ProductId); if (lstPeriod != null && lstPeriod.Count > 0) { foreach (lwg_PeriodMapping lwg in lstPeriod) { this.ltrPeriod.Text += lwg.lwg_Period.Name + ", "; } this.ltrPeriod.Text = this.ltrPeriod.Text.Substring(0, this.ltrPeriod.Text.Length - 2); } if (catalog.lwg_CatalogGenre != null && catalog.lwg_CatalogGenre.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (lwg_CatalogGenre catalogGenre in catalog.lwg_CatalogGenre) { sb.Append(catalogGenre.lwg_Genre.Name).Append(", "); } string genre = sb.ToString(); if (genre.Length > 0) { try { genre = genre.Substring(0, genre.Length - 2); } catch { ; } } this.ltrGenre.Text = genre; this.lblGenre.Visible = (genre != ""); // hide when blank field } this.ltrOrigPrint.Text = string.Empty; List <lwg_ReprintSourceMapping> lstReprintSourceMapping = new ReprintSourceBiz().GetListReprintSourceMappingByCatalogID(ProductId); if (lstReprintSourceMapping != null && lstReprintSourceMapping.Count > 0) { foreach (lwg_ReprintSourceMapping lwg in lstReprintSourceMapping) { this.ltrOrigPrint.Text += lwg.lwg_ReprintSource.Name + ", "; } this.ltrOrigPrint.Text = this.ltrOrigPrint.Text.Substring(0, this.ltrOrigPrint.Text.Length - 2); } if (product.ProductCategories != null && product.ProductCategories.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ProductCategory productCat in product.ProductCategories) { sb.Append(productCat.Category.Name).Append(", "); } string category = sb.ToString(); if (category.Length > 0) { try { category = category.Substring(0, category.Length - 3); } catch { ; } } this.ltrCategory.Text = category; } this.ltrSeries.Text = string.Empty; List <lwg_SeriesMapping> lstSeriesMapping = new SeriesBiz().GetListSeriesMappingByCatalogID(ProductId); if (lstSeriesMapping != null && lstSeriesMapping.Count > 0) { foreach (lwg_SeriesMapping lwg in lstSeriesMapping) { this.ltrSeries.Text += lwg.lwg_Series.Name + ", "; } this.ltrSeries.Text = this.ltrSeries.Text.Substring(0, this.ltrSeries.Text.Length - 2); } this.ltrText.Text = catalog.TextLang; this.lGrade.Text = catalog.Grade; this.ltrCopyrightYear.Text = catalog.CopyrightYear; InitLabels(); // hide if blank field // add Grade Product Info } else { } } else { this.Visible = false; } }
protected void dlRelatedProducts_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { RelatedProduct relatedProduct = e.Item.DataItem as RelatedProduct; Product product = relatedProduct.Product2; if (relatedProduct != null && product != null) { string productURL = SEOHelper.GetProductURL(product); Label lblPrice = e.Item.FindControl("lblPrice") as Label; if (product.ProductVariants.Count > 0) { if (!product.HasMultipleVariants) { ProductVariant productVariant = product.ProductVariants[0]; decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice); decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase); } else { ProductVariant productVariant = product.MinimalPriceProductVariant; if (productVariant != null) { decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice)); } } } Image hlImageLink = e.Item.FindControl("hlImageLink") as Image; if (hlImageLink != null) { ProductPictureCollection productPictures = product.ProductPictures; if (productPictures.Count > 0) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 84), true); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 84)); } //hlImageLink.NavigateUrl = productURL; //hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); //hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } HyperLink hlProduct = e.Item.FindControl("hlProduct") as HyperLink; if (hlProduct != null) { hlProduct.NavigateUrl = productURL; //hlProduct.Text = product.Name; } } } }
protected void BindData() { Category category = CategoryManager.GetCategoryByID(CategoryID); //настройка видимости фильтра Category baseCategory = category; Category prevCat = category; while (baseCategory.ParentCategory != null) { prevCat = baseCategory; baseCategory = baseCategory.ParentCategory; } string categoryName = baseCategory.Name.ToLower(); AdjustFilters(prevCat, categoryName); AdjustColorsFilter(categoryName, category); // настройка лидеров продаж List <BestSellersReportLine> report = OrderManager.BestSellersReport(720, 10, 1); if (report.Count == 0) { ((TwoColumn)Page.Master).SalesLeader.Visible = false; } else { int index = report.Count > 9 ? 9 : report.Count - 1; ProductVariant productVariant = ProductManager.GetProductVariantByID(report[new Random().Next(index)].ProductVariantID); if (productVariant.Product.ProductPictures.Count > 0) { ((TwoColumn)Page.Master).imgSalesLeader.ImageUrl = PictureManager.GetPictureUrl(productVariant.Product.ProductPictures[0].Picture); } else { ((TwoColumn)Page.Master).imgSalesLeader.ImageUrl = PictureManager.GetPictureUrl(productVariant.Picture); } ((TwoColumn)Page.Master).hlSalesLeader.NavigateUrl = SEOHelper.GetProductURL(productVariant.Product); } // настройка уникального предложения if (category.FeaturedProducts.Count > 0) { Product product = category.FeaturedProducts[new Random().Next(category.FeaturedProducts.Count - 1)]; if (product.ProductPictures.Count > 0) { ((TwoColumn)Page.Master).imgUniqueProposal.ImageUrl = PictureManager.GetPictureUrl(product.ProductPictures[0].Picture); } else { ((TwoColumn)Page.Master).imgUniqueProposal.ImageUrl = PictureManager.GetPictureUrl(product.ProductVariants[0].Picture); } ((TwoColumn)Page.Master).hlUniqueProposal.NavigateUrl = SEOHelper.GetProductURL(product); } else { ((TwoColumn)Page.Master).Unique.Visible = false; } lDescription.Text = category.Description; SmallDescription.Text = category.SmallDescription; int totalRecords; Int32.TryParse(productsCount.SelectedItem.Text, out pageSize); if (pageSize == 0) { pageSize = Int32.MaxValue; } SortParameter sortParameter = GetSortParameter(); List <int> psoFilterOptions = new List <int>(); psoFilterOptions.AddRange(((TwoColumn)Page.Master).PSOFilterOption); psoFilterOptions.AddRange(this.designVariant.GetDesignVariantIds()); psoFilterOptions.AddRange(this.weddingBunchVariant.GetDesignVariantIds()); psoFilterOptions.AddRange(this.houseFlowersVariant.GetDesignVariantIds()); decimal?priceMin = CommonHelper.QueryStringInt("minCost", 0); if (priceMin == 0) { var twoColumn = (TwoColumn)Page.Master; if (twoColumn != null) { priceMin = twoColumn.MinPriceConverted; } } decimal?priceMax = CommonHelper.QueryStringInt("maxCost", 0); if (priceMax == 0) { var twoColumn = (TwoColumn)Page.Master; if (twoColumn != null) { priceMax = twoColumn.MaxPriceConverted; } } int minHeight = CommonHelper.QueryStringInt("minHeight", 0); int maxHeight = CommonHelper.QueryStringInt("maxHeight", int.MaxValue); int minWidth = CommonHelper.QueryStringInt("minWidth", 0); int maxWidth = CommonHelper.QueryStringInt("maxWidth", int.MaxValue); ProductCollection productCollection = ProductManager.GetAllProducts(CategoryID, 0, null, priceMin, priceMax, pageSize, CurrentPageIndex, psoFilterOptions, (int)sortParameter.SortBy, sortParameter.Ascending, minHeight, maxHeight, minWidth, maxWidth, out totalRecords); SetItemsToGrid(totalRecords, productCollection, categoryName); }
protected void rptVariants_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var productVariant = e.Item.DataItem as ProductVariant; var pnlDownloadSample = e.Item.FindControl("pnlDownloadSample") as Panel; var hlDownloadSample = e.Item.FindControl("hlDownloadSample") as HyperLink; var iProductVariantPicture = e.Item.FindControl("iProductVariantPicture") as Image; var pnlStockAvailablity = e.Item.FindControl("pnlStockAvailablity") as Panel; var lblStockAvailablity = e.Item.FindControl("lblStockAvailablity") as Label; var pnlGiftCardInfo = e.Item.FindControl("pnlGiftCardInfo") as Panel; var txtSenderName = e.Item.FindControl("txtSenderName") as TextBox; var txtSenderEmail = e.Item.FindControl("txtSenderEmail") as TextBox; var txtCustomerEnteredPrice = e.Item.FindControl("txtCustomerEnteredPrice") as NumericTextBox; var txtQuantity = e.Item.FindControl("txtQuantity") as NumericTextBox; var btnAddToCart = e.Item.FindControl("btnAddToCart") as Button; var btnAddToWishlist = e.Item.FindControl("btnAddToWishlist") as Button; if (iProductVariantPicture != null) { var productVariantPicture = productVariant.Picture; string pictureUrl = PictureManager.GetPictureUrl(productVariantPicture, SettingManager.GetSettingValueInteger("Media.Product.VariantImageSize", 125), false); if (String.IsNullOrEmpty(pictureUrl)) { iProductVariantPicture.Visible = false; } else { iProductVariantPicture.ImageUrl = pictureUrl; } iProductVariantPicture.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), productVariant.Name); iProductVariantPicture.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), productVariant.Name); } btnAddToWishlist.Visible = SettingManager.GetSettingValueBoolean("Common.EnableWishlist"); //stock if (pnlStockAvailablity != null && lblStockAvailablity != null) { if (productVariant.ManageInventory == (int)ManageInventoryMethodEnum.ManageStock && productVariant.DisplayStockAvailability) { if (productVariant.StockQuantity > 0 || productVariant.AllowOutOfStockOrders) { lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.InStock")); } else { lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.OutOfStock")); } } else { pnlStockAvailablity.Visible = false; } } //gift cards if (pnlGiftCardInfo != null) { if (productVariant.IsGiftCard) { pnlGiftCardInfo.Visible = true; if (NopContext.Current.User != null && !NopContext.Current.User.IsGuest) { txtSenderName.Text = NopContext.Current.User.FullName; txtSenderEmail.Text = NopContext.Current.User.Email; } } else { pnlGiftCardInfo.Visible = false; } } //price entered by a customer if (productVariant.CustomerEntersPrice) { int minimumCustomerEnteredPrice = Convert.ToInt32(Math.Ceiling(CurrencyManager.ConvertCurrency(productVariant.MinimumCustomerEnteredPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency))); int maximumCustomerEnteredPrice = Convert.ToInt32(Math.Truncate(CurrencyManager.ConvertCurrency(productVariant.MaximumCustomerEnteredPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency))); txtCustomerEnteredPrice.Visible = true; txtCustomerEnteredPrice.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantId); txtCustomerEnteredPrice.Value = minimumCustomerEnteredPrice; txtCustomerEnteredPrice.MinimumValue = minimumCustomerEnteredPrice.ToString(); txtCustomerEnteredPrice.MaximumValue = maximumCustomerEnteredPrice.ToString(); txtCustomerEnteredPrice.RangeErrorMessage = string.Format(GetLocaleResourceString("Products.CustomerEnteredPrice.Range"), minimumCustomerEnteredPrice, maximumCustomerEnteredPrice); } else { txtCustomerEnteredPrice.Visible = false; } //buttons if (!productVariant.DisableBuyButton) { txtQuantity.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantId); btnAddToCart.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantId); btnAddToWishlist.ValidationGroup = string.Format("ProductVariant{0}", productVariant.ProductVariantId); txtQuantity.Value = productVariant.OrderMinimumQuantity; } else { txtQuantity.Visible = false; btnAddToCart.Visible = false; btnAddToWishlist.Visible = false; } //sample downloads if (pnlDownloadSample != null && hlDownloadSample != null) { if (productVariant.IsDownload && productVariant.HasSampleDownload) { pnlDownloadSample.Visible = true; hlDownloadSample.NavigateUrl = DownloadManager.GetSampleDownloadUrl(productVariant); } else { pnlDownloadSample.Visible = false; } } //final check - hide prices for non-registered customers if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { // } else { txtCustomerEnteredPrice.Visible = false; txtQuantity.Visible = false; btnAddToCart.Visible = false; btnAddToWishlist.Visible = false; } } }
/// <summary> /// Replaces a message template tokens /// </summary> /// <param name="productVariant">Product variant instance</param> /// <param name="template">Template</param> /// <param name="localFormat">Localization Provider Short name (en-US, de-DE, etc.)</param> /// <param name="additionalKeys">Additional keys</param> /// <param name="affiliateId">Affiliate identifier</param> /// <param name="price">Price</param> /// <returns>New template</returns> protected string replaceMessageTemplateTokens(ProductVariant productVariant, string template, string localFormat, NameValueCollection additionalKeys, int affiliateId, decimal price) { NameValueCollection tokens = new NameValueCollection(); IFormatProvider locProvider = new System.Globalization.CultureInfo(localFormat); string strHelper = template; while (strHelper.Contains("%")) { strHelper = strHelper.Substring(strHelper.IndexOf("%") + 1); string strToken = strHelper.Substring(0, strHelper.IndexOf("%")); string strFormat = ""; strHelper = strHelper.Substring(strHelper.IndexOf("%") + 1); if (strToken.Contains(":")) { strFormat = strToken.Substring(strToken.IndexOf(":")); strToken = strToken.Substring(0, strToken.IndexOf(":")); } if (tokens.Get(strToken + strFormat) == null) { switch (strToken.ToLower()) { case "store.name": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", SettingManager.StoreName)); } break; case "product.pictureurl": { var pictures = productVariant.Product.ProductPictures; if (pictures.Count > 0) { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", PictureManager.GetPictureUrl(pictures[0].PictureId))); } else { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", string.Empty)); } } break; case "pv.producturl": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", GetProductUrlWithPricelistProvider(productVariant.ProductId, AffiliateId))); } break; case "pv.price": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", price)); } break; case "pv.name": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.FullProductName)); } break; case "pv.description": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Description)); } break; case "product.description": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Product.FullDescription)); } break; case "product.shortdescription": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Product.ShortDescription)); } break; case "pv.partnumber": { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.ManufacturerPartNumber)); } break; case "product.manufacturer": { string mans = string.Empty; var productManufacturers = productVariant.Product.ProductManufacturers; foreach (ProductManufacturer pm in productManufacturers) { mans += ", " + pm.Manufacturer.Name; } if (mans.Length != 0) { mans = mans.Substring(2); } if (productManufacturers.Count > 0) { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", mans)); } } break; case "product.category": { string cats = string.Empty; var productCategories = productVariant.Product.ProductCategories; foreach (ProductCategory pc in productCategories) { cats += ", " + pc.Category.Name; } if (cats.Length != 0) { cats = cats.Substring(2); } if (productCategories.Count > 0) { tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", cats)); } } break; case "product.shippingcosts": { } break; default: { tokens.Add(strToken + strFormat, strToken + strFormat); } break; } } } foreach (string token in tokens.Keys) { template = template.Replace(string.Format(@"%{0}%", token), tokens[token]); } foreach (string token in additionalKeys.Keys) { template = template.Replace(string.Format(@"%{0}%", token), additionalKeys[token]); } return(template); }
private void BindData() { if (product != null) { string productURL = SEOHelper.GetProductURL(product); hlProduct.Text = Server.HtmlEncode(product.Name); ProductPictureCollection productPictures = product.ProductPictures; if (productPictures.Count > 0) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, ProductImageSize, true); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } hlImageLink.NavigateUrl = productURL; lShortDescription.Text = product.ShortDescription; ProductVariantCollection productVariantCollection = product.ProductVariants; if (productVariantCollection.Count > 0) { if (!product.HasMultipleVariants) { ProductVariant productVariant = productVariantCollection[0]; decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblPrice.Text += "$"; } } else { ProductVariant productVariant = product.MinimalPriceProductVariant; if (productVariant != null) { decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice)); } } } else { lblPrice.Visible = false; } #region scjaarge's change if (!lblPrice.Visible || lblPrice.Text.Trim() == string.Empty) { litOrderOrNa.Text = "Нет в наличии"; } #endregion scjaarge's change } }
/// <summary> /// Generate PriceGrabber feed /// </summary> /// <param name="stream">Stream</param> public static void GenerateFeed(Stream stream) { using (StreamWriter writer = new StreamWriter(stream)) { writer.WriteLine("Unique Retailer SKU;Manufacturer Name;Manufacturer Part Number;Product Title;Categorization;Product URL;Image URL;Detailed Description;Selling Price;Condition;Availability"); foreach (Product p in ProductManager.GetAllProducts(false)) { foreach (ProductVariant pv in ProductManager.GetProductVariantsByProductId(p.ProductId, false)) { string sku = pv.ProductVariantId.ToString(); string manufacturerName = p.ProductManufacturers.Count > 0 ? p.ProductManufacturers[0].Manufacturer.Name : String.Empty; string manufacturerPartNumber = pv.ManufacturerPartNumber; string productTitle = pv.FullProductName; string productUrl = SEOHelper.GetProductUrl(p); string imageUrl = string.Empty; var pictures = PictureManager.GetPicturesByProductId(p.ProductId, 1); if (pictures.Count > 0) { imageUrl = PictureManager.GetPictureUrl(pictures[0], SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize"), true); } else { imageUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Entity, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize")); } string description = pv.Description; string price = pv.Price.ToString(new CultureInfo("en-US", false).NumberFormat); string availability = pv.StockQuantity > 0 ? "Yes" : "No"; string categorization = "no category"; if (String.IsNullOrEmpty(description)) { description = p.FullDescription; } if (String.IsNullOrEmpty(description)) { description = p.ShortDescription; } if (String.IsNullOrEmpty(description)) { description = p.Name; } var productCategories = p.ProductCategories; if (productCategories.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (Category cat in CategoryManager.GetBreadCrumb(productCategories[0].CategoryId)) { sb.AppendFormat("{0}>", cat.Name); } sb.Length -= 1; categorization = sb.ToString(); } productTitle = RemoveSpecChars(productTitle); manufacturerPartNumber = RemoveSpecChars(manufacturerPartNumber); manufacturerName = RemoveSpecChars(manufacturerName); description = HtmlHelper.StripTags(description); description = RemoveSpecChars(description); categorization = RemoveSpecChars(categorization); writer.WriteLine("{0};{1};{2};{3};{4};{5};{6};{7};{8};New;{9}", sku, manufacturerName, manufacturerPartNumber, productTitle, categorization, productUrl, imageUrl, description, price, availability); } } } }