protected void uxAddButton_Click(object sender, EventArgs e) { if (!IsDrowDownValid()) { return; } try { if (Page.IsValid) { GoogleSpecMapping specMapping = new GoogleSpecMapping(); specMapping = SetupGoogleSpecMapping(specMapping); if (IsGoogleSpecMappingValid(specMapping)) { specMapping = DataAccessContext.GoogleFeedMappingRepository.SaveGoogleSpecMapping(uxLanguageControl.CurrentCulture, specMapping); MainContext.RedirectMainControl("GoogleSpecMappingList.ascx"); } else { uxMessage.DisplayError(Resources.GoogleSpecMappingMessages.AddDuplicate); } } } catch (Exception ex) { uxMessage.DisplayException(ex); } }
private GoogleSpecMapping SetupGoogleSpecMapping(GoogleSpecMapping specMapping) { specMapping.GoogleFeedTagValueID = uxGoogleTagValueDrop.SelectedValue; specMapping.SpecificationItemID = uxProSpecItemDrop.SelectedValue; specMapping.Value = uxProSpecValueDrop.SelectedValue; return(specMapping); }
private GoogleSpecMapping UpdateSpecMapping(GoogleSpecMapping specMapping) { specMapping = DataAccessContext.GoogleFeedMappingRepository.UpdateGoogleSpecMapping( uxLanguageControl.CurrentCulture, CurrentGoogleFeedTagValueID, CurrentSpecificationItemValue, specMapping); return(specMapping); }
private bool IsGoogleSpecMappingValid(GoogleSpecMapping specMapping) { GoogleSpecMapping result = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping( uxLanguageControl.CurrentCulture, specMapping.GoogleFeedTagValueID, specMapping.Value); return(result.IsNull); }
private void SetupField(GoogleSpecMapping specMapping) { uxGoogleTagDrop.SelectedValue = specMapping.GoogleFeedTagID; PopulateGoogleTagValueDropDown(uxGoogleTagDrop.SelectedValue); uxGoogleTagValueDrop.SelectedValue = specMapping.GoogleFeedTagValueID; uxProSpecItemDrop.SelectedValue = specMapping.SpecificationItemID; PopulateProductSpecificationValueDropDown(uxProSpecItemDrop.SelectedValue); uxProSpecValueDrop.SelectedValue = specMapping.Value; }
protected void uxUpdateButton_Click(object sender, EventArgs e) { if (!IsDrowDownValid()) { return; } try { if (Page.IsValid) { GoogleSpecMapping specMapping = new GoogleSpecMapping(); specMapping = SetupGoogleSpecMapping(specMapping); if (IsGoogleSpecMappingValid(specMapping)) { specMapping = UpdateSpecMapping(specMapping); uxMessage.DisplayMessage(Resources.GoogleSpecMappingMessages.UpdateSuccess); } else { if ((CurrentGoogleFeedTagValueID == specMapping.GoogleFeedTagValueID) && (CurrentSpecificationItemValue == specMapping.Value)) { specMapping = UpdateSpecMapping(specMapping); uxMessage.DisplayMessage(Resources.GoogleSpecMappingMessages.UpdateSuccess); } else { uxMessage.DisplayError(Resources.GoogleSpecMappingMessages.UpdateDuplicate); } } } } catch (Exception ex) { uxMessage.DisplayException(ex); } }
private void WriteProductDetails(Product product, Culture culture, XmlWriter writer, ArrayList optionMapping, ArrayList optionItems, ArrayList optionItemIDs, string itemGroupID) { //description //expiration_date //id //image_link //link //title writer.WriteStartElement("item"); //--------------- Basic Information -------------------------- //<title>Patio set</title> writer.WriteElementString("title", Server.HtmlEncode(product.Name)); //maximum 80 characters //<description>The Veracruz Oval Table.</description> writer.WriteElementString("description", Server.HtmlEncode(product.ShortDescription)); //<g:google_product_category>Apparel & Accessories > Clothing > Dresses</g:google_product_category> foreach (string categoryID in product.CategoryIDs) { writer.WriteElementString("g", "product_type", null, Server.HtmlEncode(uxDataFeedDetails.GetProductBreadcrumb(categoryID))); } //<g:product_type>Home & Garden > Kitchen & Dining > Appliances > Refrigerators</g:product_type> if (uxDataFeedDetails.GetIsUseGoogleCategory()) { writer.WriteElementString("g", "google_product_category", null, Server.HtmlEncode(uxDataFeedDetails.GetGoogleCategory())); } //<link>http://www.example.com/asp/sp.asp?cat=12&id=1030</link> // Do not return https:// for storefront prouduct & image links UrlPath productUrl = new UrlPath(UrlManager.GetProductUrl(product.ProductID, product.UrlName)); writer.WriteElementString("link", productUrl.CreateAbsoluteUri("http://" + CurrentStore.UrlName).Replace("https://", "http://")); //<g:image_link>http://www.example.com/image1.jpg</g:image_link> ProductImage productImage = product.GetPrimaryProductImage(); if (String.IsNullOrEmpty(productImage.RegularImage)) { writer.WriteElementString("g", "image_link", null, "http://" + CurrentStore.UrlName); } else { // Do not return https:// for storefront prouduct & image links writer.WriteElementString("g", "image_link", null, new Uri("http://" + CurrentStore.UrlName + "/" + productImage.RegularImage).AbsoluteUri); } //<g:condition>refurbished</g:condition> writer.WriteElementString("g", "condition", null, Server.HtmlEncode(uxDataFeedDetails.GetGoogleProductCondition())); //-------------- Prices and Availability ------------------- //<g:availability>in stock</g:availability> if (product.IsOutOfStock()) { writer.WriteElementString("g", "availability", null, "out of stock"); } else { writer.WriteElementString("g", "availability", null, "available for order"); } //<g:price>25.00</g:price> writer.WriteElementString("g", "price", null, Currency.ConvertPriceToSelectedCurrency(product.GetProductPrice(CurrentStore.StoreID).Price, currencyList[uxDataFeedDetails.GetGoogleCountryCode()])); //------------ Unique Product Identifiers --------------------- //<g:brand>Acme</g:brand> if ((product.Brand != null) && (product.Brand != String.Empty)) { writer.WriteElementString("g", "brand", null, product.Brand); } //<g:gtin>12345678</g:gtin> if ((product.Upc != null) && (product.Upc != String.Empty)) { writer.WriteElementString("g", "gtin", null, product.Upc); } //'<g:mpn>GO1234568OOGLE</g:mpn> if ((product.ManufacturerPartNumber != null) && (product.ManufacturerPartNumber != String.Empty)) { writer.WriteElementString("g", "mpn", null, product.ManufacturerPartNumber); } //'<g:item_group_id>FB3030</g:item_group_id> if (itemGroupID != null) { writer.WriteElementString("g", "item_group_id", null, itemGroupID); } //------------ For Apperal Product ----------------------- if ((product.ProductSpecifications != null) && (product.ProductSpecifications.Count > 0) && (uxDataFeedDetails.GetGoogleCategory().Contains("Apparel"))) { foreach (ProductSpecification spec in product.ProductSpecifications) { // Check for Adult GoogleSpecMapping specAdultMap = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping(culture, "4", spec.Value); if ((specAdultMap != null) && (!specAdultMap.IsNull)) { writer.WriteElementString("g", "age_group", null, "adult"); continue; } // Check For Kids else { GoogleSpecMapping specKidsMap = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping(culture, "5", spec.Value); if ((specKidsMap != null) && (!specKidsMap.IsNull)) { writer.WriteElementString("g", "age_group", null, "kids"); continue; } } // Check for Male GoogleSpecMapping specMaleMap = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping(culture, "1", spec.Value); if ((specMaleMap != null) && (!specMaleMap.IsNull)) { writer.WriteElementString("g", "gender", null, "male"); continue; } else { // Check for Female GoogleSpecMapping specFemaleMap = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping(culture, "2", spec.Value); if ((specFemaleMap != null) && (!specFemaleMap.IsNull)) { writer.WriteElementString("g", "gender", null, "female"); continue; } else { // Check for Unisex GoogleSpecMapping specUnisexMap = DataAccessContext.GoogleFeedMappingRepository.GetOneGoogleSpecMapping(culture, "3", spec.Value); if ((specUnisexMap != null) && (!specUnisexMap.IsNull)) { writer.WriteElementString("g", "gender", null, "unisex"); continue; } } } } } //----------- For Variant product ---------- if ((optionMapping != null) && (optionItems != null)) { for (int i = 0; i < optionMapping.Count; i++) { GoogleOptionMapping optionMap = ( GoogleOptionMapping )optionMapping[i]; writer.WriteElementString("g", optionMap.GoogleFeedTagName.ToLower(), null, optionItems[i].ToString()); } string optionItemIDText = String.Join("-", ( string[] )optionItemIDs.ToArray(typeof(string))); writer.WriteElementString("g", "id", null, product.Sku + "-" + optionItemIDText); } else { //<g:id>01flx</g:id> writer.WriteElementString("g", "id", null, product.Sku); } //----------- For Tax (US Only) ---------- //<g:tax> // <g:country>US</g:country> // <g:region>CA</g:region> // <g:rate>8.25</g:rate> // <g:tax_ship>y</g:tax_ship> //</g:tax> if (uxDataFeedDetails.GetGoogleCountryCode().Equals("US")) { if (product.TaxClassID == "0") //No Tax { writer.WriteStartElement("g", "tax", null); //<g:tax> writer.WriteElementString("g", "country", null, uxDataFeedDetails.GetGoogleCountryCode()); writer.WriteElementString("g", "rate", null, "0"); writer.WriteEndElement(); //</g:tax> } else { TaxClass taxClass = DataAccessContext.TaxClassRepository.GetOne(product.TaxClassID); string worldTax = "0"; bool hasUSATax = false; foreach (TaxClassRule rule in taxClass.TaxClassRule) { //For Everywhere rule if no USA rule if (rule.IsDefaultCountry) { worldTax = rule.TaxRate.ToString(); } //For US and Everywhere rule only if (rule.CountryCode.Equals("US")) { writer.WriteStartElement("g", "tax", null); //<g:tax> writer.WriteElementString("g", "country", null, uxDataFeedDetails.GetGoogleCountryCode()); if (!String.IsNullOrEmpty(rule.ZipCode)) { writer.WriteElementString("g", "region", null, rule.ZipCode); } else if (!String.IsNullOrEmpty(rule.StateCode)) { writer.WriteElementString("g", "region", null, rule.StateCode); } writer.WriteElementString("g", "rate", null, rule.TaxRate.ToString()); writer.WriteEndElement(); //</g:tax> hasUSATax = true; } } if (!hasUSATax) { writer.WriteStartElement("g", "tax", null); //<g:tax> writer.WriteElementString("g", "country", null, uxDataFeedDetails.GetGoogleCountryCode()); writer.WriteElementString("g", "rate", null, worldTax); writer.WriteEndElement(); //</g:tax> } } } //----------- For Shipping ---------- //<g:shipping> // <g:country>US</g:country> // <g:region>MA</g:region> // <g:service>Ground</g:service> // <g:price>5.95 USD</g:price> //</g:shipping> if (product.FreeShippingCost) // Free Shipping Cost { writer.WriteStartElement("g", "shipping", null); //<g:shipping> writer.WriteElementString("g", "country", null, uxDataFeedDetails.GetGoogleCountryCode()); writer.WriteElementString("g", "price", null, Currency.ConvertPriceToSelectedCurrency(Convert.ToDecimal(0), currencyList[uxDataFeedDetails.GetGoogleCountryCode()])); writer.WriteEndElement(); //</g:shipping> } else if (product.FixedShippingCost) // Override Shipping Cost { foreach (ProductShippingCost cost in product.ProductShippingCosts) { writer.WriteStartElement("g", "shipping", null); //<g:shipping> writer.WriteElementString("g", "country", null, uxDataFeedDetails.GetGoogleCountryCode()); writer.WriteElementString("g", "price", null, Currency.ConvertPriceToSelectedCurrency(cost.FixedShippingCost, currencyList[uxDataFeedDetails.GetGoogleCountryCode()])); writer.WriteEndElement(); //</g:shipping> } } else { //----------- For Shipping Weight ---------- //<g:shipping_weight>3 kg</g:shipping_weight> writer.WriteElementString("g", "shipping_weight", null, string.Format("{0:n2}", product.Weight) + " " + DataAccessContext.Configurations.GetValue("WeightUnit").ToLower()); } writer.WriteEndElement(); //</item> }