protected BlogPostListModel PrepareBlogPostListModel(BlogPagingFilteringModel command) { Guard.NotNull(command, nameof(command)); var storeId = _services.StoreContext.CurrentStore.Id; var languageId = _services.WorkContext.WorkingLanguage.Id; var isAdmin = _services.WorkContext.CurrentCustomer.IsAdmin(); var model = new BlogPostListModel(); model.PagingFilteringContext.Tag = command.Tag; model.PagingFilteringContext.Month = command.Month; if (command.PageSize <= 0) { command.PageSize = _blogSettings.PostsPageSize; } if (command.PageNumber <= 0) { command.PageNumber = 1; } DateTime?dateFrom = command.GetFromMonth(); DateTime?dateTo = command.GetToMonth(); IPagedList <BlogPost> blogPosts; if (!command.Tag.HasValue()) { blogPosts = _blogService.GetAllBlogPosts(storeId, dateFrom, dateTo, command.PageNumber - 1, command.PageSize, languageId, isAdmin); } else { blogPosts = _blogService.GetAllBlogPostsByTag(storeId, command.Tag, command.PageNumber - 1, command.PageSize, languageId, isAdmin); } model.PagingFilteringContext.LoadPagedList(blogPosts); // Prepare SEO model var parsedMonth = model.PagingFilteringContext.GetParsedMonth(); var tag = model.PagingFilteringContext.Tag; if (parsedMonth == null && tag == null) { model.MetaTitle = _blogSettings.GetLocalizedSetting(x => x.MetaTitle, storeId); model.MetaDescription = _blogSettings.GetLocalizedSetting(x => x.MetaDescription, storeId); model.MetaKeywords = _blogSettings.GetLocalizedSetting(x => x.MetaKeywords, storeId); } else { model.MetaTitle = parsedMonth != null? T("PageTitle.Blog.Month").Text.FormatWith(parsedMonth.Value.ToNativeString("MMMM", CultureInfo.InvariantCulture) + " " + parsedMonth.Value.Year) : T("PageTitle.Blog.Tag").Text.FormatWith(tag); model.MetaDescription = parsedMonth != null? T("Metadesc.Blog.Month").Text.FormatWith(parsedMonth.Value.ToNativeString("MMMM", CultureInfo.InvariantCulture) + " " + parsedMonth.Value.Year) : T("Metadesc.Blog.Tag").Text.FormatWith(tag); model.MetaKeywords = parsedMonth != null?parsedMonth.Value.ToNativeString("MMMM", CultureInfo.InvariantCulture) + " " + parsedMonth.Value.Year : tag; } Services.DisplayControl.AnnounceRange(blogPosts); model.BlogPosts = blogPosts .Select(x => { var blogPostModel = new BlogPostModel(); PrepareBlogPostModel(blogPostModel, x, false); return(blogPostModel); }) .ToList(); return(model); }