- Admin Plugin - Allow you create new screens for use on the Admin page or even replace existing Admin features.
- Retail Product Plugin - Allows you create new screens or overwrite existing retail product page features
- Checkout Plugin - Allows you add to checkout or replace existing checkout.
- Web Service Plugin - Create a RESTful Web API end point.
- Mixed plugin - A combination of plugins for use in your NopCommerce site.
- more...
What are the advantages of using a Plugin
- A isolated set of features that are distribute-able (Assuming you kept references clean)
- A isolated set of features that aren't impacted by a NopCommerce upgrade (hopefully)
- You can replace NopCommerce endpoint calls and replace it with a custom one in your plugin.
- Easy way to add non-core tables to the system
What are the dis-advantages of using a Plugin- Replacing the Checkout process with a plugin is probably not the greatest idea.
- No Referential Integrity against existing Nop tables
- Plugins that intercept core NopCommerce endpoints can become a maintenance nightmare.
Custom Plugin development challenges. You should follow these rules to try and minimize work
- Use the same Nuget package versions across all projects. Follow NuGet Best Practices. By not managing NuGet Packages correct could result in weird behaviors in your application.
- DO NOT checkin the NuGet package into source control.
- No not directly reference DLL's in the Packges folder, use the NuGet to include
- Your plugin should encapsulate all the logic required to operate
- Minimize changes to the core NopCommerce code base
- Controllers should be responsible for hydrating the current session/request and then passing that information down to helper services.
- Controllers should not contain your business logic because it's hard to test
- Services that contain logic should not be aware of HTTP Context and Session.
- Minimize size of methods (SOLID principle)
- Using a Plugin to override the Checkout Workflow is a complex task and should be a last resort.
Custom Plugin Endpoints
- Do NOT start custom route End Points with the word Admin.
routes.MapRoute("Plugins.MyCompany.Admin.Product.List",
"Admin/MyPlugin/Product/List",
new { controller = "MyProduct", action = "Admin" },
new[] { "MyCompany.Plugin.Misc.PluginName.Controllers" }
);
- Start custom routes End Points with the word Plugins
routes.MapRoute("Plugins.MyCompany.Admin.Product.List",
"Plugins/MyPlugin/Product/List",
new { controller = "MyProduct", action = "Admin" },
new[] { "MyCompany.Plugin.Misc.PluginName.Controllers" }
);
Base Plugin Folder and File Structure
- \Content
- \Controllers
- \Extensions
- \Infrastructure
- \Models
- \Scripts
- \Services
- \Validators
- \Views
- \Sql
- Description.txt
- Logo.png
- Notes.Txt
- packages.config
- RouteProvider.cs
Routes
Resources