Update some code in controller by plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Could I update code in controller by plugin.
Because I don't want to update controller for future Nop updates.
3 years ago
Yes, you can create your own classes in your plugin which inherit from nop classes and then override the methods you need to.

This is pretty straightforward for classes like services, factories - but I think a bit more involved the override controllers as you need to think about registering routes (I've never tackled this).  This might head you in the right direction..

https://www.nopcommerce.com/en/boards/topic/49853/override-existing-controller-action-in-nop-version-40

Also consider - if Nop make major changes to the code of a controller between version releases, you may need to echo theses major upgrade changes in functionality to your cloned method (in order to maintain basic Nop functionality), as well as incorporate your custom code/logic
3 years ago
It is a nice idea but depends on what changes in the Nop update

If it is like the changes required from v4.2 to v4.3 then your plugin would need to predict the future Essentially you need to know what changes are going to be required before the changes are made in the vesion for the future Nop update.

Is it possible to refernce a .dll that has not been made yet ?
3 years ago
As example,
I want to add ViewCount property to Product and Category and increase by one in every view.

So I need to add new property to Product domain and update some code in some methods.
But after that I can't update to version 4.3

Could I do that by plugin?
3 years ago
[email protected] wrote:
As example,
I want to add ViewCount property to Product and Category and increase by one in every view.

So I need to add new property to Product domain and update some code in some methods.
But after that I can't update to version 4.3

Could I do that by plugin?


You could make a plugin using an action filter to check the request to see if its a product then store that in your own domain entity with, fields like, productId, ViewCount, then increment the viewcount of each product when the filter runs. You dont need to alter the core domains.
3 years ago
[email protected] wrote:
As example,
I want to add ViewCount property to Product and Category and increase by one in every view.

So I need to add new property to Product domain and update some code in some methods.
But after that I can't update to version 4.3

Could I do that by plugin?

You can create a Widget plugin,
You don't need to "add new property to Product domain".  Create your own domain object; have a field for ProductId.
To update to version 4.3, you would likely just need to recompile.  Having the widget and own domain object would probably not need any other changes.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.