/// <summary> /// Find best SEO record using score base rules /// http://docs.virtocommerce.com/display/vc2devguide/SEO /// </summary> /// <param name="seoRecords"></param> /// <param name="store"></param> /// <param name="language"></param> /// <param name="slug"></param> /// <returns></returns> public static catalogModel.SeoInfo GetBestMatchedSeoInfo(this IEnumerable <catalogModel.SeoInfo> seoRecords, Store store, Language language, string slug = null) { catalogModel.SeoInfo result = null; if (seoRecords != null) { result = seoRecords .Select(s => { var score = 0; if (!string.IsNullOrEmpty(slug)) { score += slug.EqualsInvariant(s.SemanticUrl) ? 8 : 0; } score += store.Id.EqualsInvariant(s.StoreId) ? 4 : 0; score += language.Equals(s.LanguageCode) ? 2 : 0; score += store.DefaultLanguage.Equals(s.LanguageCode) ? 1 : 0; return(new { SeoRecord = s, Score = score }); }) .OrderByDescending(x => x.Score) .Select(x => x.SeoRecord) .FirstOrDefault(); } return(result); }
public static catalogModel.SeoInfo ToCatalogModel(this coreModel.SeoInfo seoDto) { catalogModel.SeoInfo retVal = null; if (seoDto != null) { retVal = new catalogModel.SeoInfo(); retVal.InjectFrom(seoDto); } return(retVal); }
public static SeoInfo ToWebModel(this catalogModel.SeoInfo seoDto) { SeoInfo retVal = null; if (seoDto != null) { retVal = new SeoInfo(); retVal.InjectFrom(seoDto); retVal.Slug = seoDto.SemanticUrl; retVal.Title = seoDto.PageTitle; retVal.Language = string.IsNullOrEmpty(seoDto.LanguageCode) ? Language.InvariantLanguage : new Language(seoDto.LanguageCode); } return(retVal); }