- 5
Hi,
I try to use Pavilion theme with my custom (heavy) plugin and try to override some views and controllers. And i dont want to change thirty part code(nopCommerce or any plugin,theme code).
So i was write a CustomViewEngine which insert some PartialViewLocationFormats and ViewLocationFormats.
In RouteProvider i'm insert this ViewEngine as a first Engine.
Also i override ShoppingCartController.AddProductToCart_Details and ShoppingCartController.AddProductToCart_Catalog (they are still use base methods but i manage some form data before and after Add operation.)
And ofcourse i create new route on my routeprovider.
But after installation of Pavilion theme my all overrides blow up.
My CustomViewEngine does not work. (I wan't to check my custom folders first if there is a file with same name should use my view.)
My Controllers does not work cause the request adress is diffrent new requests urls are AddProductToCartAjax,AddProductFromProductDetailsPageToCartAjax so i should override this rotues and override methods but plugins probanbly(SevenSpikes.Nop.Plugins.AjaxCart) are not open source and i would like to inheritance from original controller and use original base.methods after my custom work).
Thank You
I try to use Pavilion theme with my custom (heavy) plugin and try to override some views and controllers. And i dont want to change thirty part code(nopCommerce or any plugin,theme code).
So i was write a CustomViewEngine which insert some PartialViewLocationFormats and ViewLocationFormats.
In RouteProvider i'm insert this ViewEngine as a first Engine.
public int Priority
{
get
{
return int.MaxValue;
}
}
ViewEngines.Engines.Insert(0, new XXXViewEngine());
Also i override ShoppingCartController.AddProductToCart_Details and ShoppingCartController.AddProductToCart_Catalog (they are still use base methods but i manage some form data before and after Add operation.)
public class ShoppingCartOverridesController : Nop.Web.Controllers.ShoppingCartController
{
public override ActionResult AddProductToCart_Details(int productId, int shoppingCartTypeId, FormCollection form)
{
//Some code which use RequestFormData
var result = base.AddProductToCart_Details(productId,shoppingCartTypeId,form);
//Some code
return result;
}
}
public override ActionResult AddProductToCart_Catalog(int productId, int shoppingCartTypeId, int quantity, bool forceredirection = false)
{
//Some code which use RequestFormData
var result = AddProductToCart_Catalog(productId, shoppingCartTypeId, quantity, forceredirection)
//Some code
return result;
}
And ofcourse i create new route on my routeprovider.
//add product to cart (without any attributes and options). used on catalog pages.
routes.MapLocalizedRoute("XXX.YYY.Integration.Override.AddProductToCart-Catalog",
"addproducttocart/catalog/{productId}/{shoppingCartTypeId}/{quantity}",
new { controller = "ShoppingCartOverrides", action = "AddProductToCart_Catalog" },
new { productId = @"\d+", shoppingCartTypeId = @"\d+", quantity = @"\d+" },
new[] { "XXX.YYY.Integration.Controllers" });
//add product to cart (with attributes and options). used on the product details pages.
routes.MapLocalizedRoute("XXX.YYY.Integration.Override.AddProductToCart-Details",
"addproducttocart/details/{productId}/{shoppingCartTypeId}",
new { controller = "ShoppingCartOverrides", action = "AddProductToCart_Details" },
new { productId = @"\d+", shoppingCartTypeId = @"\d+" },
new[] { "XXX.YYY.Integration.Controllers" });
But after installation of Pavilion theme my all overrides blow up.
My CustomViewEngine does not work. (I wan't to check my custom folders first if there is a file with same name should use my view.)
My Controllers does not work cause the request adress is diffrent new requests urls are AddProductToCartAjax,AddProductFromProductDetailsPageToCartAjax so i should override this rotues and override methods but plugins probanbly(SevenSpikes.Nop.Plugins.AjaxCart) are not open source and i would like to inheritance from original controller and use original base.methods after my custom work).
Thank You