Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

[skip ci] added documentation how to setup multi store instance (#13067)

Damian Legawiec490ce7b3ac95
diff --git a/core/lib/generators/spree/install/templates/config/initializers/spree.rb b/core/lib/generators/spree/install/templates/config/initializers/spree.rb
index 984fe4935b..2f48ae0a18 100644
--- a/core/lib/generators/spree/install/templates/config/initializers/spree.rb
+++ b/core/lib/generators/spree/install/templates/config/initializers/spree.rb
@@ -29,6 +29,11 @@ end
# Default is nil and your application host will be used
# Spree.cdn_host = 'cdn.example.com'
+# Multi-store setup
+# You need to set a wildcard `root_domain` on the store to enable multi-store setup
+# all new stores will be created in a subdomain of the root domain, eg. store1.lvh.me, store2.lvh.me, etc.
+# Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'lvh.me')
+
# Use a different service for storage (S3, google, etc)
# unless Rails.env.test?
# Spree.private_storage_service_name = :amazon_public # public assets, such as product images
diff --git a/docs/developer/multi-store/quickstart.mdx b/docs/developer/multi-store/quickstart.mdx
new file mode 100644
index 0000000000..2d57a9ae12
--- /dev/null
+++ b/docs/developer/multi-store/quickstart.mdx
@@ -0,0 +1,27 @@
+---
+title: Multi-Store Spree Commerce
+sidebarTitle: Quickstart
+---
+
+Spree out of the box supports multiple stores on the same instance. This is useful for running multiple brands or multiple language versions of the same brand on the same instance.
+
+<Frame type="glass" caption="Spree multi-store setup">
+![](/images/mulit_store_978x2.png)
+</Frame>
+
+## Store resources
+
+Each Store can have its own resources. For example, a Store can have its own Products, Taxonomies, Promotions, etc.
+
+| Resource | Relationship |
+| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
+| [**Order**](/core-concepts/orders) | One Order belongs to one Store |
+| [**Product**](/core-concepts/products) | One Product can be associated with many Store(s), you can pick and choose in which Store(s) each Product will be available |
+| [**Payment Method**](/core-concepts/payments) | One Payment Method can be associated with many Store(s), you can select in which Stores given Payment Method will be available on Checkout |
+| [**Taxonomy**](/core-concepts/products#taxons-and-taxonomies) | One Taxonomy belongs to one Store |
+| [**Promotion**](/core-concepts/promotions) | One Promotion can be associated with multiple Stores |
+| **Store Credit** | One Store Credit belongs to and can be used in one Store
+
+## Setup multi-store application
+
+[Follow the setup guide](/developer/multi-store/setup) to get started.
\ No newline at end of file
diff --git a/docs/developer/multi-store/setup.mdx b/docs/developer/multi-store/setup.mdx
new file mode 100644
index 0000000000..1f33b8e514
--- /dev/null
+++ b/docs/developer/multi-store/setup.mdx
@@ -0,0 +1,40 @@
+---
+title: Multi-Store Setup
+sidebarTitle: Configuration
+---
+
+## Root domain
+
+You need to set a wildcard `root_domain` on the store to enable multi-store setup
+
+```ruby
+Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'lvh.me')
+```
+
+This will be used to generate the store URLs, eg. `store1.lvh.me`, `store2.lvh.me`, etc.
+
+`store1` part is the unique store `code` identifier, which is auto-generated based on the store name. You can change it in the admin panel in **Settings -> Domains**.
+
+<Info>
+ If you later change the `root_domain`, you will need to run:
+
+ ```ruby
+ Spree::Store.all.each(&:save)
+ ```
+
+ to update the store URLs.
+</Info>
+
+## Creating new stores
+
+After you restart your application, you will see a new option in the admin panel, under new item menu:
+
+![](/images/new_store_dropdown.png)
+
+You can also create a new store from the rails console:
+
+```ruby
+Spree::Store.create!(name: 'New Store')
+```
+
+This will create a new store with the given name, code and URL.
\ No newline at end of file
diff --git a/docs/docs.json b/docs/docs.json
index 4e0a600191..0f33a06da4 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -89,6 +89,13 @@
"group": "Use Cases",
"icon": "book-open",
"pages": [
+ {
+ "group": "Multi-Store",
+ "icon": "store",
+ "pages": [
+ "developer/multi-store/quickstart"
+ ]
+ },
{
"group": "Multi-Tenant",
"icon": "building",
diff --git a/docs/images/new_store_dropdown.png b/docs/images/new_store_dropdown.png
new file mode 100644
index 0000000000..64c296c532
Binary files /dev/null and b/docs/images/new_store_dropdown.png differ