Multiple nopCommerce sites on 1 database

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
Sorry for the email issue, we just used the email address for a short period.
Since noone was willing to share the cost for the project we decided to pay the whole cost ourselves.
14 years ago
I am developing this ...
What I did in short... you add a class module for your store with all required info including registered site address ie. nopcommerce.com
the data is stored in the database so you can have multiple stores info stored.

Then you define in the the NopContext the store class and you do something like the Customer class.
So you are able to access the store refrence from anywhere in the app by
NopContext.Current.Store.Name     .....(id, site url, address etc.. ) this is similar to current cutomer

You will need to rad the HostURl, and compare it to the Store Url in the database. then load and cach that store information. you will always have a store ID on hand to update all the tables with store id (new field) so content are always store specific.

(of course there are so many other things you need to do to get also a store specific look)
14 years ago
msargius,
could you give me more details on how you are accomplishing this challenge? I am interested in setting up multiple stores.
14 years ago
your site host must allow you to use domain pointer... so you point all domains to one site.... domain pointers are different from sub domain... a sub domain willl be sub.domain.com however domain pointer will look like
site1.com
site2.com
site3.com
maindomain.com (where the site is hosted)

the nice thing about domain pointers is that it keeps the calling domain name in the url address... so users are not presented with maindomain.com but with site1.com.

In order to read the domain name you use HttpContext.Current.Request.ServerVariable

you compare it at the start of the application request with stored records on your databse ... once you find it you have the site information that the user requires..

You change the theme of the page to that site preference... and you load the name logo, you name it through the db which are store specific.   Which means that all store settings are stored seperate from (application settings i.e. cache and security)... The only thing I am not sure about it is using SSL with this method. As I understand that each site will have one certificate... In this case you need one certificate for each store.... can we do that, I am not sure... you could become a broker yourself like ebay, or paypall...where you will act like a middle man between stores and customers...(need to investigate) However the changes in the databases etc... are enormous, as you have to add storeID to most tabhles, event topics, so each store will have different content and catalogue.... so even your admin controls have to allow you to set settings and update content of stores differently from each other. The only tables you will keep the same are localization... Membership must be seperated by stores, however you will not be able to keep the setting require unique email, unless you change the structure so you check for unique emails for each store (more work to do)

Then you need to add a management area where individual store owners can go in and change their own settings and catalogue etc...
Unless you are expecting a large volume of stores... don't go this way....it has a lot of development changes....
Disadvantages.... the system might become slow as more and more stores you host... also search engines might not like this as they might think the content is the same and will block it from searching. You really have to think about the after stage of development....deployment ... and how you will balance advantages with disadvantages... I hope I was helpfull.
14 years ago
Thanks msargius,
Could you give me an example of how and where you are using HttpContext.Current.Request.ServerVariable? I am more familiar with classic asp vb. This project is not going to used on a large scale ... we have a company that has 4-5 different divisions that need the seperate storefronts. There will only be 1 or 2 users from our company using the admin pages and managing the products and orders.
14 years ago
Excellent update from msargius - that is the way way have gone for our "non shopping cart" sites - we are looking at a large number of sites with the same functionality, low volumes of traffic. This approach means we can produce the sites quickly and at a lower cost to the customer than if we were producing each one from scratch. We simply create a navigation structure in the database and the branding /images - a simple site can easily be created in a few hours.

We were hoping to do the same with the nop_commerce site which would bring the price down and make it more affordable to clients - all we would need to do is create the branding and set up their shop in our structure. However, we stopped work on the "multi-store sites" simply because of the amount of work involved. Since the set up of the Nop site is not that difficult anyway we decided to stick with 1 site per client for the moment and see how it develops over the next year.
14 years ago
Ok ... I will give you more ideas..... There are two main files you need to modify
The most important is MembershipHttpModules.cs
This is where any user calling a page on your web site, an application start and authetication requests are sent. in here you will check for domain names so prior to any loading of any of the pages requested you can define which store is required and load the store settings from your DB.

protected void Application_BeginRequest(object sender, EventArgs e)
        {
           if (InstallerHelper.ConnectionStringIsSet())
            {
                //load store settings
                string requestedHost = CommonHelper.GetStrippedStoreHost();

                Store requestedStore = StoreManager.GetStoreByURL(requestedHost);
                if (requestedStore != null)
                { RosContext.Current.UserStore = requestedStore;
                .
                .
                .
         }

  public static string GetStrippedStoreHost()
        {
            return ServerVariables("HTTP_HOST");
        }
  
we basically we load the store information using the url and not the store name as there is no way you will be able to know the store name from the url, but otherwise is true...several stores with same name, but different url...

ok you will create a store.cs with all the fields you need, and storemanager.cs as well as collection class... think of a store as categories, a tree a main application, has stores, which each has other stores....

The second most important file, you will treat the store as you treat a user (customer)  so in ROSContext you will link the store class to it, so you can Call the store settings from your aspx pages as you would call customers
ROSContext.Current.User.Name (the user name)
ROSContext.Current.UserStore.Name (the store name)

the third most important file which are didn't mention:
is BaseNopPage.cs
In order that you can change the theme of any page this has to be done prior any initialization for the requested page.        


protected override void OnPreInit(EventArgs e)
        {
                       this.Theme = RosContext.Current.UserStore.Theme;            
                      base.OnPreInit(e);
        }    

ok... No you know the hardest part on where to start from... beside you will rewrite and edit every single table and procedure as well as almost all your program to reflect that you need info for a particular store....so categories, users, products, articles, images etc... need to be store specific...also directories you use to save store owners files, pictures, thumps etc... when you delete a store you need to delete all its info...users, products, pictures, everything.
Imagine that each store use about 10MB db space, (you created then deleted about 100 store) that is 1GB of space that is not used, that will kill your server over time.

one more think, you will need to rewrite the membership role provider. The idea behind it is....imagine a hosting company it has several websites with admin account that creates a secured user allocated space so each of us can publish our web site. now each one of us, creates his own users also to access and maintain the web sites (call them MANAGERS)  then under your application you have users which use the store that you installed (Customers). So managers can add other managers and customers (but not admin users). so you need to rewrite this to reflect this change a complete set of application modules just for managers but make sure he can only see his store as well as his sub stores(store branches) same thing for his products and categories and users. you as an admin you will need to rewrite the admin modules so you can see the complete picture .... an edit anything anywhere in the application.....

Make sure you write a very strong cleanning up procedures after every single call delete something other wise you will have a lot of garbage that is very hard to clean....Maybe at end of year you run a stored procedure that looks at everysingle record in the database and report what records in which tables are not associated with products, categories, users, stores etc... something comes up (then there is an error in your coding when you delete something.

HAPPY PROGRAMMING
14 years ago
Would anyone be interested in taking on this project for me and let me know the cost?

I need multiple stores fronts based on the url as mentioned earlier in this thread.

The users/customers can purchase from any of the storefronts, not just limited to one storefront.

The admin section can work off of 1 location. I do not need to have a complex adminsection. Our staff will be the only ones processing the orders and managing the products.


Thanks
14 years ago
I can do it for you if you want....send me an email to [email protected] with contact info and exact requirements
14 years ago
Hello guys,

So in looking at all the steps for the conversion with a lot of help from msargius', I have come up with the following list of points that will need to covered in order to convert NopCommerce to a multiple store 1 db/ 1 codebase website.

Please let me know if I'm missing anything.

1. The steps I have identified for this process so far are:
2. Add StoreID column to all the tables in current/live Db.
3. Modify the Create new Db script to create StoreID column to enable the automated setup of new Stores with Unique StoreIDs.
4. Modify the Insert Data Script - add Client ID.
5. Modify the Insert Sample Data Script - add Client ID (Low priority).
6. Modify all the stored procedure to take into account StoreID variable (416 sprocs in total).
7. Modify the data provider code in NopCommerce > Libraries > Nop.DataAccess.SqlServer - add Client ID.
8. Modify SessionStart code to set the HttpContext.Current.Session[StoreID] based store specific URL used to access the website.
9. Rewrite file get/store code to make file operations such as storing and retrieving photos etc. StoreID-Specific.
10. Configure page init code to select the right theme based on StoreID at startup.
Membership? Not sure about this one.

I am mostly concerned about testing due to the surface are of the changes that need to be made.
Has anyone started any work on this?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.