コード例 #1
0
ファイル: Events.cs プロジェクト: devverma1/SmartStore.net
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("GMC"))
            {
                return;
            }

            var model = eventMessage.BoundModel.CustomProperties["GMC"] as GoogleProductModel;

            if (model == null)
            {
                return;
            }

            var utcNow = DateTime.UtcNow;
            var entity = _googleService.GetGoogleProductRecord(model.ProductId);
            var insert = (entity == null);

            if (entity == null)
            {
                entity = new GoogleProductRecord
                {
                    ProductId    = model.ProductId,
                    CreatedOnUtc = utcNow
                };
            }

            // map objects
            entity.AgeGroup     = model.AgeGroup;
            entity.Color        = model.Color;
            entity.Gender       = model.Gender;
            entity.Size         = model.Size;
            entity.Taxonomy     = model.Taxonomy;
            entity.Material     = model.Material;
            entity.Pattern      = model.Pattern;
            entity.Export       = model.Exporting;
            entity.UpdatedOnUtc = utcNow;

            entity.IsTouched = entity.IsTouched();

            if (!insert && !entity.IsTouched)
            {
                _googleService.DeleteGoogleProductRecord(entity);
                return;
            }

            if (insert)
            {
                _googleService.InsertGoogleProductRecord(entity);
            }
            else
            {
                _googleService.UpdateGoogleProductRecord(entity);
            }
        }
コード例 #2
0
        public ActionResult ProductEditTab(int productId)
        {
            var model = new GoogleProductModel {
                ProductId = productId
            };
            var entity = _googleService.GetGoogleProductRecord(productId);

            if (entity != null)
            {
                model.Taxonomy  = entity.Taxonomy;
                model.Gender    = entity.Gender;
                model.AgeGroup  = entity.AgeGroup;
                model.Color     = entity.Color;
                model.Size      = entity.Size;
                model.Material  = entity.Material;
                model.Pattern   = entity.Pattern;
                model.Exporting = entity.Export;
            }

            ViewBag.DefaultCategory = _settings.DefaultGoogleCategory;
            ViewBag.DefaultGender   = T("Common.Auto");
            ViewBag.DefaultAgeGroup = T("Common.Auto");
            ViewBag.DefaultColor    = _settings.Color;
            ViewBag.DefaultSize     = _settings.Size;
            ViewBag.DefaultMaterial = _settings.Material;
            ViewBag.DefaultPattern  = _settings.Pattern;

            var ci = CultureInfo.InvariantCulture;

            if (_settings.Gender.HasValue() && _settings.Gender != PluginHelper.NotSpecified)
            {
                ViewBag.DefaultGender = T("Plugins.Feed.Froogle.Gender" + ci.TextInfo.ToTitleCase(_settings.Gender));
            }

            if (_settings.AgeGroup.HasValue() && _settings.AgeGroup != PluginHelper.NotSpecified)
            {
                ViewBag.DefaultAgeGroup = T("Plugins.Feed.Froogle.AgeGroup" + ci.TextInfo.ToTitleCase(_settings.AgeGroup));
            }


            ViewBag.AvailableGenders = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "male", Text = T("Plugins.Feed.Froogle.GenderMale")
                },
                new SelectListItem {
                    Value = "female", Text = T("Plugins.Feed.Froogle.GenderFemale")
                },
                new SelectListItem {
                    Value = "unisex", Text = T("Plugins.Feed.Froogle.GenderUnisex")
                }
            };

            ViewBag.AvailableAgeGroups = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "adult", Text = T("Plugins.Feed.Froogle.AgeGroupAdult")
                },
                new SelectListItem {
                    Value = "kids", Text = T("Plugins.Feed.Froogle.AgeGroupKids")
                },
            };

            var result = PartialView(model);

            result.ViewData.TemplateInfo = new TemplateInfo {
                HtmlFieldPrefix = "CustomProperties[GMC]"
            };
            return(result);
        }
コード例 #3
0
        public ActionResult ProductEditTab(int productId)
        {
            var culture = CultureInfo.InvariantCulture;
            var model   = new GoogleProductModel {
                ProductId = productId
            };
            var    entity       = _googleFeedService.GetGoogleProductRecord(productId);
            string notSpecified = T("Common.Unspecified");

            if (entity != null)
            {
                model.Taxonomy              = entity.Taxonomy;
                model.Gender                = entity.Gender;
                model.AgeGroup              = entity.AgeGroup;
                model.IsAdult               = entity.IsAdult;
                model.Color                 = entity.Color;
                model.Size                  = entity.Size;
                model.Material              = entity.Material;
                model.Pattern               = entity.Pattern;
                model.Export2               = entity.Export;
                model.Multipack2            = entity.Multipack;
                model.IsBundle              = entity.IsBundle;
                model.EnergyEfficiencyClass = entity.EnergyEfficiencyClass;
                model.CustomLabel0          = entity.CustomLabel0;
                model.CustomLabel1          = entity.CustomLabel1;
                model.CustomLabel2          = entity.CustomLabel2;
                model.CustomLabel3          = entity.CustomLabel3;
                model.CustomLabel4          = entity.CustomLabel4;
            }
            else
            {
                model.Export2 = true;
            }

            ViewBag.DefaultCategory              = "";
            ViewBag.DefaultColor                 = "";
            ViewBag.DefaultSize                  = "";
            ViewBag.DefaultMaterial              = "";
            ViewBag.DefaultPattern               = "";
            ViewBag.DefaultGender                = notSpecified;
            ViewBag.DefaultAgeGroup              = notSpecified;
            ViewBag.DefaultIsAdult               = "";
            ViewBag.DefaultMultipack2            = "";
            ViewBag.DefaultIsBundle              = "";
            ViewBag.DefaultEnergyEfficiencyClass = notSpecified;
            ViewBag.DefaultCustomLabel           = "";
            ViewBag.LanguageSeoCode              = Services.WorkContext.WorkingLanguage.UniqueSeoCode.EmptyNull().ToLower();

            // We do not have export profile context here, so we simply use the first profile.
            var profile = _exportService.Value.GetExportProfilesBySystemName(GmcXmlExportProvider.SystemName).FirstOrDefault();

            if (profile != null)
            {
                var config = XmlHelper.Deserialize(profile.ProviderConfigData, typeof(ProfileConfigurationModel)) as ProfileConfigurationModel;
                if (config != null)
                {
                    ViewBag.DefaultCategory = config.DefaultGoogleCategory;
                    ViewBag.DefaultColor    = config.Color;
                    ViewBag.DefaultSize     = config.Size;
                    ViewBag.DefaultMaterial = config.Material;
                    ViewBag.DefaultPattern  = config.Pattern;

                    if (config.Gender.HasValue() && config.Gender != GmcXmlExportProvider.Unspecified)
                    {
                        ViewBag.DefaultGender = T("Plugins.Feed.Froogle.Gender" + culture.TextInfo.ToTitleCase(config.Gender));
                    }

                    if (config.AgeGroup.HasValue() && config.AgeGroup != GmcXmlExportProvider.Unspecified)
                    {
                        ViewBag.DefaultAgeGroup = T("Plugins.Feed.Froogle.AgeGroup" + culture.TextInfo.ToTitleCase(config.AgeGroup));
                    }
                }
            }

            ViewBag.AvailableCategories = model.Taxonomy.HasValue()
                                ? new List <SelectListItem> {
                new SelectListItem {
                    Text = model.Taxonomy, Value = model.Taxonomy, Selected = true
                }
            }
                                : new List <SelectListItem>();

            ViewBag.AvailableGenders = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "male", Text = T("Plugins.Feed.Froogle.GenderMale")
                },
                new SelectListItem {
                    Value = "female", Text = T("Plugins.Feed.Froogle.GenderFemale")
                },
                new SelectListItem {
                    Value = "unisex", Text = T("Plugins.Feed.Froogle.GenderUnisex")
                }
            };

            ViewBag.AvailableAgeGroups = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "adult", Text = T("Plugins.Feed.Froogle.AgeGroupAdult")
                },
                new SelectListItem {
                    Value = "kids", Text = T("Plugins.Feed.Froogle.AgeGroupKids")
                },
            };

            ViewBag.AvailableEnergyEfficiencyClasses = T("Plugins.Feed.Froogle.EnergyEfficiencyClasses").Text
                                                       .SplitSafe(",")
                                                       .Select(x => new SelectListItem {
                Value = x, Text = x
            })
                                                       .ToList();

            var result = PartialView(model);

            result.ViewData.TemplateInfo = new TemplateInfo {
                HtmlFieldPrefix = "CustomProperties[GMC]"
            };
            return(result);
        }
コード例 #4
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("GMC"))
            {
                return;
            }

            var model = eventMessage.BoundModel.CustomProperties["GMC"] as GoogleProductModel;

            if (model == null)
            {
                return;
            }

            var utcNow = DateTime.UtcNow;
            var entity = _googleService.GetGoogleProductRecord(model.ProductId);
            var insert = (entity == null);

            if (entity == null)
            {
                entity = new GoogleProductRecord
                {
                    ProductId    = model.ProductId,
                    CreatedOnUtc = utcNow
                };
            }

            entity.AgeGroup              = model.AgeGroup;
            entity.Color                 = model.Color;
            entity.Gender                = model.Gender;
            entity.Size                  = model.Size;
            entity.Taxonomy              = model.Taxonomy;
            entity.Material              = model.Material;
            entity.Pattern               = model.Pattern;
            entity.Export                = model.Export2;
            entity.UpdatedOnUtc          = utcNow;
            entity.Multipack             = model.Multipack2 ?? 0;
            entity.IsBundle              = model.IsBundle;
            entity.IsAdult               = model.IsAdult;
            entity.EnergyEfficiencyClass = model.EnergyEfficiencyClass;
            entity.CustomLabel0          = model.CustomLabel0;
            entity.CustomLabel1          = model.CustomLabel1;
            entity.CustomLabel2          = model.CustomLabel2;
            entity.CustomLabel3          = model.CustomLabel3;
            entity.CustomLabel4          = model.CustomLabel4;

            entity.IsTouched = entity.IsTouched();

            if (!insert && !entity.IsTouched)
            {
                _googleService.DeleteGoogleProductRecord(entity);
                return;
            }

            if (insert)
            {
                _googleService.InsertGoogleProductRecord(entity);
            }
            else
            {
                _googleService.UpdateGoogleProductRecord(entity);
            }
        }