Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Sitemap - Allow selecting a language to generate the XML file
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak committed Jun 24, 2020
1 parent a5384b9 commit 14074dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Grand.Web/Controllers/CommonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public virtual async Task<IActionResult> SetLanguage(

//helper method to redirect users.
public virtual IActionResult InternalRedirect(string url, bool permanentRedirect)
{
{
//ensure it's invoked from our GenericPathRoute class
if (HttpContext.Items["grand.RedirectFromGenericPathRoute"] == null ||
!Convert.ToBoolean(HttpContext.Items["grand.RedirectFromGenericPathRoute"]))
Expand Down Expand Up @@ -286,16 +286,24 @@ public virtual async Task<IActionResult> Sitemap([FromServices] CommonSettings c

//available even when a store is closed
[CheckAccessClosedStore(true)]
public virtual async Task<IActionResult> SitemapXml(int? id,
public virtual async Task<IActionResult> SitemapXml(int? id, string seocode,
[FromServices] ILanguageService languageService,
[FromServices] CommonSettings commonSettings)
{
if (!commonSettings.SitemapEnabled)
return RedirectToRoute("HomePage");

var lang = _workContext.WorkingLanguage;
if (!string.IsNullOrEmpty(seocode))
{
var seolang = (await languageService.GetAllLanguages()).FirstOrDefault(x => x.UniqueSeoCode.ToLowerInvariant() == seocode.ToLowerInvariant());
if (seolang != null)
lang = seolang;
}
var siteMap = await _mediator.Send(new GetSitemapXml() {
Id = id,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Language = lang,
Store = _storeContext.CurrentStore,
UrlHelper = Url,
});
Expand Down

0 comments on commit 14074dd

Please sign in to comment.