Skip to content

Commit

Permalink
#112 Add backward compatibility routes for product tags
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanovM committed Sep 15, 2018
1 parent 9ab784c commit c7e0b5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class BackwardCompatibility2XController : BasePublicController
private readonly ICategoryService _categoryService;
private readonly IManufacturerService _manufacturerService;
private readonly INewsService _newsService;
private readonly IProductTagService _productTagService;
private readonly IProductService _productService;
private readonly ITopicService _topicService;
private readonly IUrlRecordService _urlRecordService;
Expand All @@ -29,6 +30,7 @@ public BackwardCompatibility2XController(IBlogService blogService,
ICategoryService categoryService,
IManufacturerService manufacturerService,
INewsService newsService,
IProductTagService productTagService,
IProductService productService,
ITopicService topicService,
IUrlRecordService urlRecordService,
Expand All @@ -38,6 +40,7 @@ public BackwardCompatibility2XController(IBlogService blogService,
this._categoryService = categoryService;
this._manufacturerService = manufacturerService;
this._newsService = newsService;
this._productTagService = productTagService;
this._productService = productService;
this._topicService = topicService;
this._urlRecordService = urlRecordService;
Expand Down Expand Up @@ -118,6 +121,16 @@ public virtual IActionResult RedirectVendorById(int vendorId)
return RedirectToRoutePermanent("Vendor", new { SeName = _urlRecordService.GetSeName(vendor) });
}

//in versions 3.00-4.00 we had ID in product tag URLs
public virtual IActionResult RedirectProductTagById(int productTagId)
{
var productTag = _productTagService.GetProductTagById(productTagId);
if (productTag == null)
return RedirectToRoutePermanent("HomePage");

return RedirectToRoutePermanent("ProductsByTag", new { SeName = _urlRecordService.GetSeName(productTag) });
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void RegisterRoutes(IRouteBuilder routeBuilder)
//vendors
routeBuilder.MapLocalizedRoute("", "vendor/{vendorId:min(0)}/{SeName?}",
new { controller = "BackwardCompatibility2X", action = "RedirectVendorById" });

//product tags
routeBuilder.MapLocalizedRoute("", "producttag/{productTagId:min(0)}/{SeName?}",
new { controller = "BackwardCompatibility2X", action = "RedirectProductTagById" });
}

#endregion
Expand Down

0 comments on commit c7e0b5e

Please sign in to comment.