var productTemplateViewPath = productModelFactory.PrepareProductTemplateViewPath(product); if (productTemplateViewPath == "ProductTemplate.YourTemplate") { filterContext.Result = new RedirectToRouteResult("Nop.Group.Name.Front.YourTemplate", new { SeName = seName }); }
6. Create Controller action in YourController
public IActionResult YourTemplateFront(string seName) { if (string.IsNullOrEmpty(seName)) throw new ArgumentNullException("No product found with the specified SeName");
var urlRecord = _urlRecordService.GetBySlug(seName); if (urlRecord == null) return RedirectToRoute("HomePage");
var product = _productService.GetProductById(urlRecord.EntityId); if (product == null) throw new ArgumentNullException("No product found with the specified id"); .... var model = _productModelFactory.PrepareProductDetailsModel(product);
var productTemplate = _productTemplateService.GetProductTemplateById(product.ProductTemplateId);