Configuring Multiple Stores with Multiple Domains in Virto Commerce: A Comprehensive Guide

Virto Commerce offers a powerful feature that allows you to configure multiple stores with multiple domains on the same environment. This means you can build and manage different websites for various brands or business entities using a single platform and codebase.

In this blog post, we will walk you through the steps to set up and configure multiple stores with their own domain names, enabling you to efficiently manage content, marketing activities, and orders for each store.

For the demo purpose, I use B2B Theme with different presets in default\config\settings_data.json file.

Prerequisites:

Before proceeding with the configuration of multiple stores, make sure you have completed the following prerequisites:

  1. Deploy the Virto Commerce Platform and Storefront using the Virto Commerce documentation.
  2. Configure the shared cms-content folder between the Storefront and Platform components.
  3. Set up and configure languages, currencies, and other relevant settings.
  4. Configure or import the necessary catalog(s) for your stores.
  5. Configure price lists and price list assignments based on your pricing strategy.
  6. Configure inventory management according to your business requirements.
  7. Download Default B2B Theme or Build a custom one.
  8. In addition to the steps mentioned above, it is important to configure the DNS settings for each domain associated with the stores. Make sure to update the DNS records to point the domain names (e.g., store1-domain.com, store2-domain.com) to the appropriate IP address or hostname where your Virto Commerce instance is hosted.

Configuring Multiple Stores

Follow these steps to configure multiple stores with their own domains in Virto Commerce:

Step 1. Create and Configure Store1:

  1. Assign the appropriate catalog to Store1.
  2. Configure price list assignments for Store1, if required.

Ensure that Store1 has unique domain name, such as https://store1-domain.com.

Step 2. Deploy Theme

  1. Go to Content, Select Store and Upload the desired theme for the store.
  2. Navigate to store

The default path for the CMS-CONTENT folder is wwwroot\cms-content\Themes{StoreId}.

You can automate theme deployment to the shared CMS-CONTENT folder to streamline the process.

Step 3. Configure Next Store:

Follow the same process as Step 1 and 2 to create and configure Store2.

Each store should have its own domain name, such as https://store2-domain.com.

How to Share the Same Theme Between Multiple Stores

It is possible to share the same theme between multiple stores by utilizing the LiquidThemeEngine:BaseThemePath setting in the storefront’s appsettings.json file.

This approach allows each store’s specific CMS-CONTENT folder to contain unique store customizations.

Summary

Configuring multiple stores with multiple domains in Virto Commerce provides great flexibility and convenience for managing distinct web experiences on the same platform. You can easily set up and configure multiple stores with their own domain names, assign catalogs and price lists, and upload custom themes.

Additionally, you have the option to share themes between stores to streamline development efforts. With Virto Commerce, you can create a cohesive and efficient multi-store environment to meet the unique needs of your business.

We hope this guide helps you leverage the powerful capabilities of Virto Commerce in managing multiple stores with ease. If you have any further questions or need assistance, please don’t hesitate to reach out to our support team.

Happy configuring!

1 Like

Hi @OlegoO ,
Thanks for helpful article :+1:
Question: Can the URL be a sub-domain, for example https://b2b.store1.com and https://custom.store1.com for two different stores?
Thanks,
Sherif

Yes. It can be third (any) level domain.

2 Likes

Hi @OlegoO ,

I have another question, could be related to this post, or we can move to a thread by itself if you see necessary

If I have a Storefront for a client, and I want to switch between two or more themes for the same user-session, how can I do that?

For example, we have an Angular2 application that is wrapped in a Virto Theme and the client is using that. For the same client, we want to offer the B2b-vue-theme for shopping, with a different subdomain. So domain 1. https://wam.myClient.com.au uses Angular2 theme, and for domain 2 https://b2b.myClient.com.au we want to use the vue-b2b theme, while keeping the same authentication sign-on session

Is this possible?
Would I intercept the request, in vc-storefront, and render a different theme?
Thanks in advance for your help

To keep the same authorization session, you need to have a root domain that is shared. So clients need to authenticate to myclient.com.au and then wam… and b2b… websites can have access to the authenticated session.

Depending on the version of the storefront, there are different ways how the theme can be switched.

I am using the latest version of the Storefront, so what are the ways the theme can be switched, based on url?

First, Store URL should be set up in VC Backend, in your examples https://wam.myClient.com.au and https://b2b.myClient.com.au

Then, both stores should be linked in VC Backend.

Finally, you allow Share cookies across subdomains. To share cookies across vc-storefront sites, such as wam.myClient.com.au and b2b.myClient.com.au, you can specify the Cookie.Domain as .myClient.com.au. Please check this reference: Share authentication cookies among ASP.NET apps | Microsoft Learn

You can pass Cookie.Domain in vc-storefront by CookieAuthenticationOptions section in appsettings.json or by using C# code in vc-storefront/VirtoCommerce.Storefront/Startup.cs at dev · VirtoCommerce/vc-storefront (github.com).

If all is ok, after sign-in “.AspNetCore.Identity.Application” cookies should be assigned with .myClient.com.au domain.

Awesome :pray: Thanks @OlegoO , and @sasha

So, I should not intercept the request path, in one Storefront app, and based on the URL path of this request, send a different theme to the user-browser, I should have two different Storefront apps and share authentication between them? Yes?

Virto Storefront supports multiple stores and can resolve the current store by domain automatically if you configured site URL in the VC Admin.

To switch between two or more themes for the same user session, you need to follow my instruction and configure auth cookie domain because by default auth cookie is related to the current domain and if you switch to another site/domain, the browser doesn’t send auth cookie to the server. You can use a single Virto Storefront application.

Two different Storefront apps also work. But as I said, the magic is in the usage of wildcard domain .myClient.com.au and sharing of authentication cookies.

1 Like

Yes, clear :+1:t3: thanks again @OlegoO