nopCommerce plugin for separate database best practice

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi,

Sorry if this has been asked before, but using google, forum search, and nopCommerce docs, I couldn't find what I'm looking for.

What is the nopCommerce recommended way for a plugin to save data to a separate database?  For example:  
1. Where should we put the connection string?
2. Where/how should we configure database services?
3. Any other best practice for connecting to an external db?

I'm looking at nopCommerce 4.3, so this question is also specifically for it.  As I understand it, 4.3 is using linqDb instead of EF.

Thank you in advance
4 years ago
whizzy wrote:
Hi,

Sorry if this has been asked before, but using google, forum search, and nopCommerce docs, I couldn't find what I'm looking for.

What is the nopCommerce recommended way for a plugin to save data to a separate database?  For example:  
1. Where should we put the connection string?
2. Where/how should we configure database services?
3. Any other best practice for connecting to an external db?

I'm looking at nopCommerce 4.3, so this question is also specifically for it.  As I understand it, 4.3 is using linqDb instead of EF.

Thank you in advance


I'm not sure about how to store plugin data to separate database but you can do the same thing by using Web API or any API services.

You need to develop a separate project of web API and just call that API from your plugin and you can save any data to another database.
4 years ago
SuperNopCommerce wrote:
Hi,
I'm not sure about how to store plugin data to separate database but you can do the same thing by using Web API or any API services.

You need to develop a separate project of web API and just call that API from your plugin and you can save any data to another database.


Thanks Pratik.  I did consider building a separate web api for the plugin to hit, however, this would mean adding another layer/system in between.  If it's a complex data/logic that needs to be saved, it's probably worth it.  Otherwise, it feels it's a bit over-engineering.  And for the project I'm working on now, I only need order data to be saved to a separate database whenever a new order comes in.

Best
Mario
4 years ago
Hi,

If you want only order data then I would request you use database trigger.

You need just to figure out some tables related to Orders ( like Order, OrderItems) in nopCommerce and add triggers on those tables.

In that trigger, add logic to pull data from nopCommerce db to your db.  If your database is on another server then use Linked server of MS SQL.

There is another way instead of triggers.
Write Stored Procedure to pull data from nopCommerce database to your database and put this stored procedure in SQL jobs which runs every specific time of interval.

Thank you.
4 years ago
Thanks Pratik!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.