NopCommerce 4.0 - How can I override NopViewComponent?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I want override ViewComponent threw plugin.



Any idea about that?
Any help will be appreciated.

Thank you
- Raju
6 years ago
rajupaladiya wrote:
I want override ViewComponent threw plugin.



Any idea about that?
Any help will be appreciated.

Thank you
- Raju


None of ViewComponent's methods are virtual so you cannot override them.
6 years ago
seanrock wrote:

None of ViewComponent's methods are virtual so you cannot override them.


Thanks seanrock for your answer.

I fixed it with just copy viewComponent file in my plugin and make change as I want. And it's working.

Also thank apfelsine for help. :)

Best Regards.
- Raju
6 years ago
Do you mind to share how do you override the view components in nopCommerce through plugin? For example, if I would like to implement some modifications to "HomepageProducts" view component, what are the steps to copy the "HomepageProducts" view component into plugin folder and make nopCommerce picks up the modified version form the plugin?
6 years ago
cpsee wrote:
Do you mind to share how do you override the view components in nopCommerce through plugin? For example, if I would like to implement some modifications to "HomepageProducts" view component, what are the steps to copy the "HomepageProducts" view component into plugin folder and make nopCommerce picks up the modified version form the plugin?
.

You also done through plugin.


public class TestViewEngine : IViewLocationExpander  
{

    public void PopulateValues(ViewLocationExpanderContext context)
    {
        //nothing to do here.

    }
    public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
    {

        if (context.AreaName == null && context.ViewName == "Components/OrderTotals/Default")
        {
            viewLocations = new string[] { $"/Plugins/Demo/Views/{{0}}.cshtml"
                }.Concat(viewLocations);

        }

        return viewLocations;
    }




after this you have to register view engine with the help of INopStartup.

May be INopStartup you have to inherit.  

for more information you have to look at this url.

https://stackoverflow.com/questions/47572810/nop-commerce-custom-view-engine-for-icomponents-view-doesnt-work-in-nopcommerce

https://weblogs.asp.net/imranbaloch/view-location-expander-aspnet5-mvc6


Huhh.. that's set .

Hope you will understand.
6 years ago
Thanks, this is indeed very helpful info.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.