public coreModel.SeoInfo UpsertSeo(coreModel.SeoInfo seo)
        {
            if (seo == null)
            {
                throw new ArgumentNullException("seo");
            }

            coreModel.SeoInfo retVal = null;
            using (var repository = _repositoryFactory())
            {
                var sourceEntry = seo.ToDataModel();
                var targetEntry = repository.SeoUrlKeywords.FirstOrDefault(x => x.Id == seo.Id || (x.Keyword == sourceEntry.Keyword && x.ObjectType == sourceEntry.ObjectType));
                if (targetEntry == null)
                {
                    repository.Add(sourceEntry);
                }
                else
                {
                    sourceEntry.Patch(targetEntry);
                }
                CommitChanges(repository);
                seo.Id = sourceEntry.Id ?? targetEntry.Id;
                retVal = repository.SeoUrlKeywords.First(x => x.Id == seo.Id).ToCoreModel();
            }
            return(retVal);
        }
		public static coreModel.SeoInfo ToCoreModel(this dataModel.SeoUrlKeyword urlKeyword)
		{
			var retVal = new coreModel.SeoInfo();
			retVal.InjectFrom(urlKeyword);
			retVal.LanguageCode = urlKeyword.Language;
			retVal.SemanticUrl = urlKeyword.Keyword;
			retVal.PageTitle = urlKeyword.Title;
			return retVal;
		}
Example #3
0
        public static coreModel.SeoInfo ToCoreModel(this dataModel.SeoUrlKeyword urlKeyword)
        {
            var retVal = new coreModel.SeoInfo();

            retVal.InjectFrom(urlKeyword);
            retVal.LanguageCode = urlKeyword.Language;
            retVal.SemanticUrl  = urlKeyword.Keyword;
            retVal.PageTitle    = urlKeyword.Title;
            return(retVal);
        }
Example #4
0
        public static dataModel.SeoUrlKeyword ToDataModel(this coreModel.SeoInfo seo)
        {
            var retVal = new dataModel.SeoUrlKeyword();

            retVal.InjectFrom(seo);

            retVal.Keyword  = seo.SemanticUrl;
            retVal.Language = seo.LanguageCode;
            retVal.Title    = seo.PageTitle;

            return(retVal);
        }
Example #5
0
		public CsvProduct()
		{
			SeoInfos = new List<SeoInfo>();
			Reviews = new List<EditorialReview>();
			PropertyValues = new List<PropertyValue>();
			Images = new List<Image>();
			Assets = new List<Asset>();


			Price = new Price() { Currency = CurrencyCodes.USD };
			Inventory = new InventoryInfo();
			EditorialReview = new EditorialReview();
			Reviews = new List<EditorialReview>();
			Reviews.Add(EditorialReview);
			SeoInfo = new SeoInfo();
			SeoInfos = new List<SeoInfo>();
			SeoInfos.Add(SeoInfo);
		}
Example #6
0
		public CsvProduct()
		{
			SeoInfos = new List<SeoInfo>();
			Reviews = new List<EditorialReview>();
			PropertyValues = new List<PropertyValue>();
			Images = new List<Image>();
			Assets = new List<Asset>();


			Price = new Price() { Currency = "USD" };
			Inventory = new InventoryInfo();
			EditorialReview = new EditorialReview();
			Reviews = new List<EditorialReview>();
			Reviews.Add(EditorialReview);
			SeoInfo = new SeoInfo() { ObjectType = typeof(CatalogProduct).Name };
			SeoInfos = new List<SeoInfo>();
			SeoInfos.Add(SeoInfo);
		}
Example #7
0
        public object Clone()
        {
            var retVal = new SeoInfo();

            retVal.CreatedBy = CreatedBy;
            retVal.CreatedDate = CreatedDate;
            retVal.ModifiedBy = ModifiedBy;
            retVal.ModifiedDate = ModifiedDate;

            retVal.SemanticUrl = SemanticUrl;
            retVal.PageTitle = PageTitle;
            retVal.MetaDescription = MetaDescription;
            retVal.ImageAltDescription = ImageAltDescription;
            retVal.MetaKeywords = MetaKeywords;
            retVal.ObjectId = ObjectId;
            retVal.ObjectType = ObjectType;
            retVal.IsActive = IsActive;
            retVal.LanguageCode = LanguageCode;
            return retVal;
        }
Example #8
0
        public object Clone()
        {
            var retVal = new SeoInfo();

            retVal.CreatedBy    = CreatedBy;
            retVal.CreatedDate  = CreatedDate;
            retVal.ModifiedBy   = ModifiedBy;
            retVal.ModifiedDate = ModifiedDate;

            retVal.SemanticUrl         = SemanticUrl;
            retVal.PageTitle           = PageTitle;
            retVal.MetaDescription     = MetaDescription;
            retVal.ImageAltDescription = ImageAltDescription;
            retVal.MetaKeywords        = MetaKeywords;
            retVal.ObjectId            = ObjectId;
            retVal.ObjectType          = ObjectType;
            retVal.IsActive            = IsActive;
            retVal.LanguageCode        = LanguageCode;
            return(retVal);
        }
        public virtual coreModel.SeoInfo ToModel(coreModel.SeoInfo seoInfo)
        {
            seoInfo.Id           = Id;
            seoInfo.CreatedBy    = CreatedBy;
            seoInfo.CreatedDate  = CreatedDate;
            seoInfo.ModifiedBy   = ModifiedBy;
            seoInfo.ModifiedDate = ModifiedDate;

            seoInfo.LanguageCode        = Language;
            seoInfo.SemanticUrl         = Keyword;
            seoInfo.PageTitle           = Title;
            seoInfo.ImageAltDescription = ImageAltDescription;
            seoInfo.IsActive            = IsActive;
            seoInfo.MetaDescription     = MetaDescription;
            seoInfo.MetaKeywords        = MetaKeywords;
            seoInfo.ObjectId            = ObjectId;
            seoInfo.ObjectType          = ObjectType;
            seoInfo.StoreId             = StoreId;

            return(seoInfo);
        }
        public virtual dataModel.SeoUrlKeyword FromModel(coreModel.SeoInfo seoInfo, PrimaryKeyResolvingMap pkMap)
        {
            pkMap.AddPair(seoInfo, this);

            Id           = seoInfo.Id;
            CreatedBy    = seoInfo.CreatedBy;
            CreatedDate  = seoInfo.CreatedDate;
            ModifiedBy   = seoInfo.ModifiedBy;
            ModifiedDate = seoInfo.ModifiedDate;

            Language            = seoInfo.LanguageCode;
            Keyword             = seoInfo.SemanticUrl;
            Title               = seoInfo.PageTitle;
            ImageAltDescription = seoInfo.ImageAltDescription;
            IsActive            = seoInfo.IsActive;
            MetaDescription     = seoInfo.MetaDescription;
            MetaKeywords        = seoInfo.MetaKeywords;
            ObjectId            = seoInfo.ObjectId;
            ObjectType          = seoInfo.ObjectType;
            StoreId             = seoInfo.StoreId;

            return(this);
        }
        private coreModel.CatalogProduct UpdateProduct(webModel.Product product)
        {
            var moduleProduct = product.ToModuleModel(_blobUrlResolver);
            if (moduleProduct.Id == null)
            {
                if (moduleProduct.SeoInfos == null || !moduleProduct.SeoInfos.Any())
                {
                    var slugUrl = GenerateProductDefaultSlugUrl(product);
                    if (!string.IsNullOrEmpty(slugUrl))
                    {
                        var catalog = _catalogService.GetById(product.CatalogId);
                        var defaultLanguageCode = catalog.Languages.First(x => x.IsDefault).LanguageCode;
                        var seoInfo = new SeoInfo
                        {
                            LanguageCode = defaultLanguageCode,
                            SemanticUrl = slugUrl
                        };
                        moduleProduct.SeoInfos = new SeoInfo[] { seoInfo };
                    }
                }

                base.CheckCurrentUserHasPermissionForObjects(CatalogPredefinedPermissions.Create, moduleProduct);
                return _itemsService.Create(moduleProduct);
            }
            else
            {
                base.CheckCurrentUserHasPermissionForObjects(CatalogPredefinedPermissions.Update, moduleProduct);
               _itemsService.Update(new[] { moduleProduct });
            }

            return null;
        }