public ActionResult GenerateUrl(string id, string mode)
        {
            var url = string.Empty;
            var aff = HccApp.ContactServices.Affiliates.FindByUserId(HccApp.CurrentCustomerId.ConvertTo <int>());

            switch (mode)
            {
            case "Category":
                var cat = HccApp.CatalogServices.Categories.FindManySnapshots(new List <string> {
                    id
                }).First();
                url  = UrlRewriter.BuildUrlForCategory(cat);
                url += "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId;
                break;

            case "Product":
                var prod = HccApp.CatalogServices.Products.FindWithCache(id);
                url  = UrlRewriter.BuildUrlForProduct(prod);
                url += "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId;
                break;

            default:
                url = id + "?" + WebAppSettings.AffiliateQueryStringName + "=" + aff.AffiliateId;
                break;
            }

            return(Json(url));
        }
Exemplo n.º 2
0
        protected void btnNew_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            ContentBlock b = MyPage.MTApp.ContentServices.Columns.FindBlock(this.BlockId);

            if (b != null)
            {
                //Inserting
                //SettingsManager.GetSettingList("ProductGrid");
                foreach (string product in ProductPicker1.SelectedProducts)
                {
                    ContentBlockSettingListItem c = new ContentBlockSettingListItem();
                    Product p = MyPage.MTApp.CatalogServices.Products.Find(product);
                    c.Setting1 = product;
                    c.Setting2 = p.Sku;
                    c.Setting3 = p.ProductName;
                    c.Setting4 = Page.ResolveUrl(ImageHelper.GetValidImage(p.ImageFileSmall, true));
                    c.Setting5 = UrlRewriter.BuildUrlForProduct(p, this.Page);
                    c.Setting6 = p.SitePrice.ToString();
                    c.ListName = "ProductGrid";
                    b.Lists.AddItem(c);
                    MyPage.MTApp.ContentServices.Columns.UpdateBlock(b);
                }
                LoadItems(b);
            }
        }
        public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Price Product " + p.ProductName))
            {
                this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales);
            }
            this.IsFirstItem = false;
            this.IsLastItem  = false;
            this.Item        = p;
            using (profiler.Step("Image Url Product" + p.ProductName))
            {
                this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
                    mtapp,
                    p.Bvin,
                    p.ImageFileSmall,
                    mtapp.IsCurrentRequestSecure());
            }
            using (profiler.Step("Product Link " + p.ProductName))
            {
                this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                                  mtapp.CurrentRequestContext.RoutingContext,
                                                                  string.Empty);
            }
            this.SwatchDisplay = MerchantTribe.Commerce.Utilities.ImageHelper.GenerateSwatchHtmlForProduct(p, mtapp);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Set parameter values with provided product object
        /// </summary>
        /// <param name="p">Product information.</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public SingleProductViewModel(Product p, HotcakesApplication hccApp)
        {
            if (p == null)
            {
                throw new ArgumentNullException("Product");
            }
            if (hccApp == null)
            {
                throw new ArgumentNullException("HotcakesApplication");
            }

            UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales);
            Item      = p;

            ProductLink = UrlRewriter.BuildUrlForProduct(p);
            ImageUrls   = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, p);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp);

#pragma warning disable 0612, 0618
            ImageUrl = DiskStorage.ProductImageUrlSmall(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.IsCurrentRequestSecure());

            OriginalImageUrl = DiskStorage.ProductImageUrlOriginal(
                hccApp,
                p.Bvin,
                p.ImageFileSmall,
                hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
#pragma warning restore 0612, 0618
        }
Exemplo n.º 5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ucProductPerformance.ProductId = ProductId;

            PageMessageBox = ucMessageBox;

            if (!string.IsNullOrEmpty(ReturnUrl) && ReturnUrl == "Y")
            {
                lnkBacktoAbandonedCartsReport.Visible     = true;
                lnkBacktoAbandonedCartsReport.NavigateUrl =
                    "~/DesktopModules/Hotcakes/Core/Admin/reports/AbandonedCarts/view.aspx";
            }
            else
            {
                lnkBacktoAbandonedCartsReport.Visible = false;
            }

            var product = HccApp.CatalogServices.Products.FindWithCache(ProductId);

            lnkViewInStore.NavigateUrl = UrlRewriter.BuildUrlForProduct(product);

            btnCreateBundle.Visible = !product.IsBundle;
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Set default values using parameterized constructor
        ///     <remarks>
        ///         This generally called from the products controller to set proper urls and product link for the bundled product
        ///     </remarks>
        /// </summary>
        /// <param name="bp">Parameter passed for existing  BundledProduct object</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public BundledProductViewModel(BundledProductAdv bp, HotcakesApplication hccApp)
        {
            BundledProductAdv = bp;
            Item = bp.BundledProduct;

            ProductLink = UrlRewriter.BuildUrlForProduct(BundledProductAdv.BundledProduct);
            ImageUrls   = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, BundledProductAdv.BundledProduct);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(BundledProductAdv.BundledProduct, hccApp);
        }
Exemplo n.º 7
0
        private string RemoteUrl(Product p)
        {
            var temp = UrlRewriter.BuildUrlForProduct(p);

            temp = temp.Replace("\\", "/");

            if (temp.ToLower().StartsWith("http://") == false)
            {
                return(Path.Combine(HccApp.CurrentStore.RootUrl(), temp.TrimStart('/')));
            }
            return(temp);
        }
Exemplo n.º 8
0
        public static string RenderReceiptSurvey(Order o, HotcakesApplication app)
        {
            var sb = new StringBuilder();

            sb.AppendLine("<!– Start Bizrate POS Code –>");

            sb.AppendLine("<script language=\"JavaScript\">");
            sb.AppendLine("// var passin_x =;");
            sb.AppendLine("//var passin_y =500;");
            sb.AppendLine("var orderId='" + o.OrderNumber + "';");
            sb.AppendLine("// var z_index =; //default 9995");
            sb.AppendLine("var cartTotal=" + o.TotalGrand.ToString("0.00") + ";");
            sb.AppendLine("var billingZipCode='" + o.BillingAddress.PostalCode + "';");
            sb.Append("var productsPurchased='");

            for (var i = 0; i < 5; i++)
            {
                if (i < o.Items.Count)
                {
                    var p = app.CatalogServices.Products.FindBySku(o.Items[i].ProductSku);
                    if (p == null)
                    {
                        p = new Product();
                    }
                    var url = UrlRewriter.BuildUrlForProduct(p);
                    sb.Append("URL=" + url);
                    sb.Append("^SKU=" + p.Sku);
                    sb.Append("^GTIN="); // UPC, EIN or other global unique number
                    sb.Append("^PRICE=" + o.Items[i].LineTotal / o.Items[i].Quantity);
                }
                else
                {
                    sb.Append("URL=^SKU=^GTIN=^PRICE=");
                }
                if (i < 4)
                {
                    sb.Append("|");
                }
            }
            sb.AppendLine("';");

            sb.AppendLine("</script>");
            sb.AppendLine("<script type=\"text/javascript\" src=\"https://eval.bizrate.com/js/pos_" +
                          app.CurrentStore.Settings.Analytics.ShopZillaId + ".js\">");
            sb.AppendLine("</script>");

            sb.AppendLine("<!– End Bizrate POS Code –>\n");


            sb.AppendLine(RenderTracker(o, app));

            return(sb.ToString());
        }
Exemplo n.º 9
0
        public SingleProductJsonModel(Product product, HotcakesApplication app)
        {
            ProductLink   = UrlRewriter.BuildUrlForProduct(product);
            ProductName   = product.ProductName;
            ImageSmallUrl = DiskStorage.ProductImageUrlSmall(app, product.Bvin, product.ImageFileSmall,
                                                             app.IsCurrentRequestSecure());
            ImageSmallAltText = product.ImageFileSmallAlternateText;
            ProductSku        = product.Sku;
            Bvin = product.Bvin;

            var up = app.PriceProduct(product, app.CurrentCustomer, null, app.CurrentlyActiveSales);

            UserPrice = up.DisplayPrice();
        }
Exemplo n.º 10
0
 public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
 {
     this.UserPrice   = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null);
     this.IsFirstItem = false;
     this.IsLastItem  = false;
     this.Item        = p;
     this.ImageUrl    = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
         mtapp,
         p.Bvin,
         p.ImageFileSmall,
         mtapp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
     this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                       mtapp.CurrentRequestContext.RoutingContext,
                                                       string.Empty);
 }
Exemplo n.º 11
0
        private void LoadCart(CartViewModel model)
        {
            Order Basket = SessionManager.CurrentShoppingCart(MTApp.OrderServices, MTApp.CurrentStore);

            if (Basket == null)
            {
                return;
            }
            model.CurrentOrder = Basket;

            if ((Basket.Items == null) || ((Basket.Items != null) && (Basket.Items.Count <= 0)))
            {
                model.CartEmpty = true;
                return;
            }

            foreach (LineItem li in model.CurrentOrder.Items)
            {
                CartLineItemViewModel ci = new CartLineItemViewModel();
                ci.Item = li;

                Product associatedProduct = li.GetAssociatedProduct(MTApp);
                if (associatedProduct != null)
                {
                    ci.ShowImage = true;
                    ci.ImageUrl  = MerchantTribe.Commerce.Storage
                                   .DiskStorage.ProductVariantImageUrlMedium(
                        MTApp, li.ProductId,
                        associatedProduct.ImageFileSmall,
                        li.VariantId, Request.IsSecureConnection);

                    ci.LinkUrl = UrlRewriter.BuildUrlForProduct(associatedProduct,
                                                                MTApp.CurrentRequestContext.RoutingContext,
                                                                "OrderBvin=" + li.OrderBvin + "&LineItemId=" + li.Id);
                }


                if (li.LineTotal != li.LineTotalWithoutDiscounts)
                {
                    ci.HasDiscounts = true;
                }

                model.LineItems.Add(ci);
            }
        }
Exemplo n.º 12
0
        private List <SideMenuItem> LoadProducts(DateTime start, DateTime end)
        {
            System.DateTime s = start;
            System.DateTime e = end;

            List <Product> t = MTApp.ReportingTopSellersByDate(s, e, 10);

            List <SideMenuItem> result = new List <SideMenuItem>();

            foreach (Product p in t)
            {
                SideMenuItem item = new SideMenuItem();
                item.Title = p.ProductName;
                item.Name  = p.ProductName;
                item.Url   = UrlRewriter.BuildUrlForProduct(p, MTApp.CurrentRequestContext.RoutingContext, string.Empty);
                result.Add(item);
            }
            return(result);
        }
Exemplo n.º 13
0
        private void LoadCart(CartViewModel model)
        {
            model.CurrentOrder = CurrentCart ?? new Order();

            if (CurrentCart == null || CurrentCart.Items == null || CurrentCart.Items.Count == 0)
            {
                model.CartEmpty = true;
                return;
            }
            model.Rates = GetRates();

            for (var i = CurrentCart.Items.Count - 1; i >= 0; i--)
            {
                var lineItem = CurrentCart.Items[i];
                var product  = lineItem.GetAssociatedProduct(HccApp);
                if (product != null)
                {
                    var ci = new CartLineItemViewModel
                    {
                        Item      = lineItem,
                        Product   = product,
                        ShowImage = true,
                        ImageUrl  = DiskStorage.ProductVariantImageUrlSmall(
                            HccApp, lineItem.ProductId,
                            product.ImageFileSmall,
                            lineItem.VariantId, Request.IsSecureConnection),
                        LinkUrl = UrlRewriter.BuildUrlForProduct(product,
                                                                 new { lineItem.OrderBvin, LineItemId = lineItem.Id }),
                        HasDiscounts = lineItem.HasAnyDiscounts
                    };

                    model.LineItems.Add(ci);
                }
                else
                {
                    CurrentCart.Items.RemoveAt(i);
                    HccApp.OrderServices.Orders.Update(CurrentCart);
                }
            }

            UpdateCartCustomerInfo();
        }
Exemplo n.º 14
0
        /// <summary>
        ///     Set parameter values with provided product object
        /// </summary>
        /// <param name="p">Product information.</param>
        /// <param name="hccApp">An instance of the Hotcakes Application context.</param>
        public SingleProductViewModel(Product p, HotcakesApplication hccApp)
        {
            if (p == null)
            {
                throw new ArgumentNullException("Product");
            }
            if (hccApp == null)
            {
                throw new ArgumentNullException("HotcakesApplication");
            }

            UserPrice = hccApp.PriceProduct(p, hccApp.CurrentCustomer, null, hccApp.CurrentlyActiveSales);
            Item      = p;

            ProductLink          = UrlRewriter.BuildUrlForProduct(p);
            ProductAddToCartLink = UrlRewriter.BuildUrlForProductAddToCart(p);
            ImageUrls            = new ProductImageUrls();
            ImageUrls.LoadProductImageUrls(hccApp, p);

            SwatchDisplay = ImageHelper.GenerateSwatchHtmlForProduct(p, hccApp);
        }
        //
        // GET: /ContentBlocks/Top10Products/

        public ActionResult Index(ContentBlock b)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            System.DateTime s        = new System.DateTime(1900, 1, 1);
            System.DateTime e        = new System.DateTime(3000, 12, 31);
            List <Product>  products = MTApp.ReportingTopSellersByDate(s, e, 10);

            foreach (Product p in products)
            {
                SideMenuItem item = new SideMenuItem();
                item.Title = p.ProductName;
                item.Name  = p.ProductName;
                item.Url   = UrlRewriter.BuildUrlForProduct(p, MTApp.CurrentRequestContext.RoutingContext, string.Empty);
                item.Name += " - " + p.SitePrice.ToString("C");
                model.Items.Add(item);
            }

            model.Title = "Top Sellers";
            return(View(model));
        }
Exemplo n.º 16
0
        private List <SideMenuItem> LoadProducts(DateTime start, DateTime end)
        {
            var s = start;
            var e = end;

            var t = HccApp.ReportingTopSellersByDate(s, e, 10);

            var result = new List <SideMenuItem>();

            foreach (var p in t)
            {
                var item = new SideMenuItem
                {
                    Title = p.ProductName,
                    Name  = p.ProductName,
                    Url   = UrlRewriter.BuildUrlForProduct(p)
                };
                result.Add(item);
            }
            return(result);
        }
Exemplo n.º 17
0
        public static string BuildForStore(HotcakesApplication app)
        {
            if (app == null)
            {
                return(string.Empty);
            }

            var root     = app.CurrentStore.RootUrl();
            var rootNode = new SiteMapNode();

            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (var cat in app.CatalogServices.Categories.FindAll())
            {
                var caturl = UrlRewriter.BuildUrlForCategory(cat);

                // Skip Pages with Outbound links as they aren't supported in sitemap format
                var temp = caturl.ToUpperInvariant();
                if (temp.StartsWith("HTTP:") || temp.StartsWith("HTTPS:"))
                {
                    continue;
                }

                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (var p in app.CatalogServices.Products.FindAllPagedWithCache(1, 3000))
            {
                var produrl = UrlRewriter.BuildUrlForProduct(p);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return(rootNode.RenderAsXmlSiteMap());
        }
Exemplo n.º 18
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            System.DateTime s = new System.DateTime(1900, 1, 1);
            System.DateTime e = new System.DateTime(3000, 12, 31);
            List <Product>  products;

            products = app.ReportingTopSellersByDate(s, e, 10);
            foreach (Product p in products)
            {
                SideMenuItem item = new SideMenuItem();
                item.Title = p.ProductName;
                item.Name  = p.ProductName;
                item.Url   = UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                item.Name += " - " + p.SitePrice.ToString("C");
                model.Items.Add(item);
            }

            model.Title = "Top Sellers";

            return(RenderModel(model));
        }
        public ActionResult Index()
        {
            var model = new SideMenuViewModel();

            var            s = new DateTime(1900, 1, 1);
            var            e = new DateTime(3000, 12, 31);
            List <Product> products;

            products = HccApp.ReportingTopSellersByDate(s, e, 10);
            foreach (var p in products)
            {
                var item = new SideMenuItem
                {
                    Title = p.ProductName,
                    Name  = p.ProductName,
                    Url   = UrlRewriter.BuildUrlForProduct(p)
                };
                item.Name += " - " + p.SitePrice.ToString("C");
                model.Items.Add(item);
            }

            model.Title = "Top Sellers";
            return(View(model));
        }
Exemplo n.º 20
0
        private void BuildGoogleFeed()
        {
            //
            // the majority of the code to follow is based upon the excellent blog below:
            // http://blog.codenamed.nl/2015/05/14/creating-a-google-shopping-feed-with-c/
            //

            // get an instance of the store application
            var HccApp = HotcakesApplication.Current;

            var totalProducts = 0;
            var feed          = new FeedInfo();

            // get the store URL based upon SSL
            var storeUrl = Request.IsSecureConnection ? HccApp.CurrentStore.RootUrlSecure() : HccApp.CurrentStore.RootUrl();
            // used to get currency code
            var regionInfo = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID);

            feed.Link    = storeUrl;
            feed.Title   = HccApp.CurrentStore.StoreName;
            feed.Updated = DateTime.Now;
            feed.Entries = new List <EntryInfo>();

            // find all products in the store that are active
            var searchCriteria = new ProductSearchCriteria
            {
                DisplayInactiveProducts = false
            };

            // using the search instead of querying the Products directly to use cache
            var products = HccApp.CatalogServices.Products.FindByCriteria(searchCriteria, 1, int.MaxValue, ref totalProducts);

            // non-shipping
            var shippingInfo = new ShippingInfo {
                Price = Constants.HARDCODED_PRICE_ZERO
            };
            // not taxable (e.g., software)
            var taxInfo = new TaxInfo {
                Rate = Constants.HARDCODED_PRICE_ZERO
            };

            // iterate through each product and add it to the feed
            foreach (var product in products)
            {
                var productUrl = UrlRewriter.BuildUrlForProduct(product);

                var productEntry = new EntryInfo
                {
                    Availablity           = GetStockMessage(product),            // OPTIONS: preorder, in stock, out of stock
                    Condition             = Constants.CONDITION_NEW,             // OPTIONS: new, refurbished, used
                    Description           = product.LongDescription,
                    GoogleProductCategory = Constants.HARDCODED_GOOGLE_CATEGORY, // hard-coded for this example project (see property attributes)
                    Id          = product.Sku,
                    ImageLink   = DiskStorage.ProductImageUrlMedium(HccApp, product.Bvin, product.ImageFileMedium, Request.IsSecureConnection),
                    Link        = productUrl,
                    MobileLink  = productUrl,
                    Price       = string.Format(Constants.CURRENCY_TEXT_FORMAT, product.SitePrice.ToString(Constants.CURRENCY_FORMAT), regionInfo.ISOCurrencySymbol),
                    ProductType = GetFirstAvailableCategory(HccApp, product.Bvin), // put your preferred site category here
                    Title       = product.ProductName,
                    MPN         = product.Sku,                                     // this should be replaced with real data
                    Brand       = product.VendorId,                                // this should be replaced with real data
                    Color       = string.Empty,
                    Gender      = Constants.GENDER_UNISEX,                         // OPTIONS: male, female, unisex
                    AgeGroup    = Constants.AGE_GROUP_ADULT,                       // OPTIONS: newborn, infant, toddler, kids, adult
                    GTIN        = GenerateGTIN()                                   // this should be replaced with real data
                };

                // this could and should be iterated on to show shipping options for up to 100 locations
                productEntry.Shipping = new List <ShippingInfo>();
                productEntry.Shipping.Add(shippingInfo);

                // this could and should be iterated on to show taxes for up to 100 locations
                productEntry.Tax = new List <TaxInfo>();
                productEntry.Tax.Add(taxInfo);

                feed.Entries.Add(productEntry);
            }

            // simply done to display the feed in the textbox
            // alternatives could be to send this through a web service or other means
            txtGoogleFeed.Text = feed.SerializeObject();
        }
Exemplo n.º 21
0
        private void LoadProduct()
        {
            var p = HccApp.CatalogServices.Products.Find(ProductId);

            if (p != null)
            {
                chkActive.Checked     = p.Status == ProductStatus.Active;
                chkSearchable.Checked = p.IsSearchable;
                if (p.IsBundle)
                {
                    rbBehaviour.SelectedValue = "B";
                }
                else if (p.IsGiftCard)
                {
                    rbBehaviour.SelectedValue = "GC";
                    pnlPricing.Visible        = false;
                }

                if (ddlTemplateList.Items.FindItemByValue(p.TemplateName) != null)
                {
                    ddlTemplateList.ClearSelection();
                    ddlTemplateList.Items.FindItemByValue(p.TemplateName).Selected = true;
                }

                chkFeatured.Checked = p.Featured;

                SkuField.Text       = p.Sku;
                txtProductName.Text = p.ProductName;

                chkUserPrice.Checked   = p.IsUserSuppliedPrice;
                chkHideQty.Checked     = p.HideQty;
                txtUserPriceLabel.Text = p.UserSuppliedPriceLabel;

                if (!p.IsUserSuppliedPrice)
                {
                    ListPriceField.Enabled    = true;
                    CostField.Enabled         = true;
                    SitePriceField.Enabled    = true;
                    ListPriceField.Text       = p.ListPrice.ToString("C");
                    CostField.Text            = p.SiteCost.ToString("C");
                    SitePriceField.Text       = p.SitePrice.ToString("C");
                    PriceOverrideTextBox.Text = p.SitePriceOverrideText;
                }
                else
                {
                    ListPriceField.Enabled       = false;
                    CostField.Enabled            = false;
                    SitePriceField.Enabled       = false;
                    PriceOverrideTextBox.Enabled = false;
                    ListPriceField.Text          = string.Empty;
                    CostField.Text            = string.Empty;
                    SitePriceField.Text       = string.Empty;
                    PriceOverrideTextBox.Text = string.Empty;
                    rfvCostField.Enabled      = false;
                    rfvListPrice.Enabled      = false;
                    rfvSitePrice.Enabled      = false;
                }

                LongDescriptionField.Text = p.LongDescription;

                TaxExemptField.Checked = p.TaxExempt;
                if (lstTaxClasses.Items.FindByValue(p.TaxSchedule.ToString()) != null)
                {
                    lstTaxClasses.ClearSelection();
                    lstTaxClasses.Items.FindByValue(p.TaxSchedule.ToString()).Selected = true;
                }
                if (lstManufacturers.Items.FindItemByValue(p.ManufacturerId) != null)
                {
                    lstManufacturers.ClearSelection();
                    lstManufacturers.Items.FindItemByValue(p.ManufacturerId).Selected = true;
                }
                if (lstVendors.Items.FindItemByValue(p.VendorId) != null)
                {
                    lstVendors.ClearSelection();
                    lstVendors.Items.FindItemByValue(p.VendorId).Selected = true;
                }

                LoadImagePreview(p);
                if (string.IsNullOrEmpty(p.ImageFileSmallAlternateText))
                {
                    p.ImageFileSmallAlternateText = p.ProductName + " " + p.Sku;
                }
                SmallImageAlternateTextField.Text = p.ImageFileSmallAlternateText;
                if (string.IsNullOrEmpty(p.ImageFileMediumAlternateText))
                {
                    p.ImageFileMediumAlternateText = p.ProductName + " " + p.Sku;
                }
                MediumImageAlternateTextField.Text = p.ImageFileMediumAlternateText;

                if (lstProductType.Items.FindItemByValue(p.ProductTypeId) != null)
                {
                    lstProductType.ClearSelection();
                    lstProductType.Items.FindItemByValue(p.ProductTypeId).Selected = true;
                }
                // Added this line to stop errors on immediate load and save - Marcus
                LastProductType = p.ProductTypeId;

                if (!string.IsNullOrWhiteSpace(p.PreContentColumnId))
                {
                    if (ddlPreContentColumn.Items.FindByValue(p.PreContentColumnId) != null)
                    {
                        ddlPreContentColumn.Items.FindByValue(p.PreContentColumnId).Selected = true;
                    }
                }
                if (!string.IsNullOrWhiteSpace(p.PostContentColumnId))
                {
                    if (ddlPostContentColumn.Items.FindByValue(p.PostContentColumnId) != null)
                    {
                        ddlPostContentColumn.Items.FindByValue(p.PostContentColumnId).Selected = true;
                    }
                }

                txtKeywords.Text        = p.Keywords;
                txtMetaTitle.Text       = p.MetaTitle;
                txtMetaDescription.Text = p.MetaDescription;
                txtMetaKeywords.Text    = p.MetaKeywords;

                txtWeight.Text = Math.Round(p.ShippingDetails.Weight, 3).ToString();
                txtLength.Text = Math.Round(p.ShippingDetails.Length, 3).ToString();
                txtWidth.Text  = Math.Round(p.ShippingDetails.Width, 3).ToString();
                txtHeight.Text = Math.Round(p.ShippingDetails.Height, 3).ToString();

                ExtraShipFeeField.Text = p.ShippingDetails.ExtraShipFee.ToString("C");
                if (ddlShipType.Items.FindByValue(((int)p.ShippingMode).ToString()) != null)
                {
                    ddlShipType.ClearSelection();
                    ddlShipType.Items.FindByValue(((int)p.ShippingMode).ToString()).Selected = true;
                }
                if (lstShippingCharge.Items.FindByValue(((int)p.ShippingCharge).ToString()) != null)
                {
                    lstShippingCharge.ClearSelection();
                    lstShippingCharge.Items.FindByValue(((int)p.ShippingCharge).ToString()).Selected = true;
                }
                chkNonShipping.Checked    = p.ShippingDetails.IsNonShipping;
                chkShipSeparately.Checked = p.ShippingDetails.ShipSeparately;

                txtMinimumQty.Text = Math.Round((decimal)p.MinimumQty, 0).ToString();

                txtRewriteUrl.Text = p.UrlSlug;

                lnkViewInStore.NavigateUrl = UrlRewriter.BuildUrlForProduct(p);

                lnkClone.NavigateUrl = "ProductClone.aspx?id=" + p.Bvin;

                if (p.AllowReviews.HasValue)
                {
                    rblAllowReviews.SelectedValue = p.AllowReviews.ToString();
                }
                else
                {
                    rblAllowReviews.SelectedValue = string.Empty;
                }

                swatchpathfield.Text = p.SwatchPath;

                txtTaxonomyTags.Text = string.Join(",", HccApp.SocialService.GetTaxonomyTerms(p));
            }
        }