Multi Stores with sub domains

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Hi guys, I am having some hard time in getting the nop commerce multi store feature work in my 2 subdomains:

sub1.domain.com
sub2.domain.com

I have installed the nop files on my main domain which is domain.com (not in sub1 or sub2 subdomain) and have created the two above subdomains through the hosting admin panel.

I have also created 2 stores in nop admin panel:

URL: http://sub1.domain.com/
HOST Values: sub1.domain.com,www.sub1.domain.com

and

URL: http://sub1.domain.com/
HOST Values: sub1.domain.com,www.sub1.domain.com

Could you please give me some details about what should I change in DNS settings through hosting admin panel?
Thanks in advance.
8 years ago
Hi,

Please have a look at the following article - Setting Up Multi-stores (http://docs.nopcommerce.com/display/nc/Setting+Up+Multi-stores). I presume you're interested in steps 1-3
8 years ago
Hi thanks for your reply. I have already found this page.
Actually, I cannot understand the step 2. What is the full CNAME record that I should add in DNS settings?

Thanks again.
8 years ago
my solution for Multistore without subdomains and multiple wildcard sslzertificats.

each currency can have its own store . so fixed shippingprice per currencny are possible.

just recomple the Nop.Web.Framework  and set the store by Querystring Param setstore=storehost

example:
mystore.com?setstore=store1
mystore.com?setstore=store2

storesettings hostvalues must contains 'store1' or store2



I just read the cookie nop.customer , place the name 'store' + cookie in the settingstaple with the value from querystring.
each time CurrentStore is called  the host variable will be overwritten withe the setting from the settingtable  if available.


using System;
using System.Linq;
using Nop.Core;
using Nop.Core.Domain.Stores;
using Nop.Services.Stores;
using Nop.Core.Infrastructure;

using System.Web;
using Nop.Core.Plugins;
using Nop.Services.Configuration;


namespace Nop.Web.Framework
{
    /// <summary>
    /// Store context for web application
    /// </summary>
    public partial class WebStoreContext : BasePlugin, IStoreContext
    {
        private readonly IStoreService _storeService;
        private readonly IWebHelper _webHelper;

        private readonly ISettingService _settingService;


        private Store _cachedStore;

        public WebStoreContext(IStoreService storeService, IWebHelper webHelper, ISettingService settingService)
        {
            this._storeService = storeService;
            this._webHelper = webHelper;
            this._settingService = settingService;


        }

        /// <summary>
        /// Gets or sets the current store
        /// </summary>
        public virtual Store CurrentStore
        {
            get
            {
                if (_cachedStore != null)
                    return _cachedStore;

                //ty to determine the current store by HTTP_HOST

                var host = _webHelper.ServerVariables("HTTP_HOST");



                //giordano storeselectore
                var settstring = string.Empty;
                var cookiestring = _webHelper.ServerVariables("HTTP_COOKIE").ToString().Split(new Char[] { ';' });
                foreach (var cookieitem in cookiestring)
                {
                    if (cookieitem.Contains("customer"))
                    {
                        settstring = cookieitem;
                    }
                }


                if (!String.IsNullOrEmpty(_webHelper.QueryString<string>("setstore").ToString()) && !string.IsNullOrEmpty(settstring))
                {
                    string setstore = _webHelper.QueryString<string>("setstore").ToString();
                    var setting = new Nop.Core.Domain.Configuration.Setting();
                    setting.Name = "giordano.store-" + settstring;
                    setting.Value = setstore;
                    _settingService.SetSetting(setting.Name, setting.Value);

                }


                var customerstore = _settingService.GetSettingByKey<string>("giordano.store-" + settstring);
                if (!String.IsNullOrEmpty(customerstore))
                {
                    host = customerstore;
                }


                //orginal


                var allStores = _storeService.GetAllStores();
                var store = allStores.FirstOrDefault(s => s.ContainsHostValue(host));

                if (store == null)
                {
                    //load the first found store
                    store = allStores.FirstOrDefault();
                }
                if (store == null)
                    throw new Exception("No store could be loaded");

                _cachedStore = store;
                return _cachedStore;
            }
        }
    }
}
8 years ago
a.m. wrote:
Hi,

Please have a look at the following article - Setting Up Multi-stores. I presume you're interested in steps 1-3


Hello,

i would like to setup multistore using subdomains. I followed your instruction, but without succes.

1. I created one subdomain http://b2b.podistostreho.si/ with Plesk and forward it with CNAME record to main domain podistostreho.si.
2. But, when i tried to create ALIAS for this subdomain, it Plesk doesn't allow, 'Alias for this domain already exist'.
3. If i browse subdomain, it shows welcome index.html file, created with Plesk.
4. In nop admin section i created store with host values: b2b.podistostreho.si, www.b2b.podistostreho.si
and URL http://b2b.podistostreho.si

My domain is test domain without DNS records, for browsing you must add this record in your's PC host datafile:

212.44.105.150 podistostreho.si
212.44.105.150 b2b.podistostreho.si

Please help.

Thanks and kind regards, Boris
8 years ago
borisvel wrote:
Hi,

Please have a look at the following article - Setting Up Multi-stores. I presume you're interested in steps 1-3

Hello,

i would like to setup multistore using subdomains. I followed your instruction, but without succes.

1. I created one subdomain http://b2b.podistostreho.si/ with Plesk and forward it with CNAME record to main domain podistostreho.si.
2. But, when i tried to create ALIAS for this subdomain, it Plesk doesn't allow, 'Alias for this domain already exist'.
3. If i browse subdomain, it shows welcome index.html file, created with Plesk.
4. In nop admin section i created store with host values: b2b.podistostreho.si, www.b2b.podistostreho.si
and URL http://b2b.podistostreho.si

My domain is test domain without DNS records, for browsing you must add this record in your's PC host datafile:

212.44.105.150 podistostreho.si
212.44.105.150 b2b.podistostreho.si

Please help.

Thanks and kind regards, Boris


I think if it doesn't allow you add record, then you need to contact your server admin / support. You can also check an article published here and here.
8 years ago
Hello,

thanks for your post. I'll check it with my host provider.

Kind regards, Boris
8 years ago
Hi Boris

Our Source let's set up Nop als Multistore with one Domain and without Subdomains. Therefore we only need one ssl certificate for all countries, currencies etc.

in your case, I think you should setup up 2 domains as follows:

www.podistostreho.si
b2b.podistostreho.si

and then follow Andrei's article - Setting Up Multi-stores.

regards
André
giordano.ch
8 years ago
Thanks Andre,

i'm going to try your way to.

Kind regards, Boris
8 years ago
Hello,

we found solution, i hope.

Plesk 9.5 doesn't allow to create alias for domain with existing domain or subdomain at same host.

So i didn't create any additional domain, i just created alias for main domain. I did setup also new 'alias' store in nop admin and allocated some products just for main store and some products just for store with 'alias' name.

If i browse main domain or alias domain, i see only allocated products for each store. It seems it works correctly?

Could some nopcommerce developer check this?

Thanks and kind regards, Boris
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.