You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/guides/6.multistore/3.patterns/3.data/1.different-config-same-integration.md
+209Lines changed: 209 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,3 +6,212 @@ navigation:
6
6
---
7
7
8
8
# Different configurations for the same integration
9
+
10
+
When building a multistore solution, you'll often need to use the same integration with different configurations across your stores. This guide explains how to efficiently manage multiple configurations for the same integration while maintaining a clean and maintainable codebase.
11
+
12
+
**What You'll Learn**
13
+
14
+
::list{type="success"}
15
+
- Understanding when you need different configurations for the same integration
16
+
- How to implement store-specific integration configurations
17
+
- Best practices for managing integration configurations across multiple stores
18
+
- Using environment variables to reduce code duplication
19
+
::
20
+
21
+
## When Do You Need Multiple Configurations?
22
+
23
+
Let's explore some common scenarios where you might need different configurations for the same integration:
24
+
25
+
### Use Case 1: Different Content in Stores Using a CMS Integration
26
+
27
+
Imagine running two stores where the same CMS integration is used, but each store needs distinct content. For instance, a fashion store and a sports store have entirely different marketing copy and visuals.
28
+
29
+
### Use Case 2: Multiple Product Catalogs for an eCommerce Integration
30
+
31
+
Suppose your solution uses an integration with SAP Commerce Cloud (SAPCC). You want to build two stores—one for B2C and another for B2B. Each store requires a different product catalog.
catalogId: 'b2bProductsCatalog', // store specific value
69
+
// ...
70
+
},
71
+
}
72
+
}
73
+
```
74
+
75
+
After this operation, the file structure will look like this:
76
+
77
+
```bash
78
+
apps/
79
+
├── storefront-middleware
80
+
| ├── integrations
81
+
|| └── sapcc
82
+
|| └── config.ts # base config will be overridden by stores config
83
+
└── stores
84
+
├── b2c
85
+
| ├── storefront-middleware
86
+
|| ├── integrations
87
+
||| └── sapcc
88
+
||| └── config.ts # new file for b2c store
89
+
└── b2b
90
+
└── storefront-middleware
91
+
└── integrations
92
+
└── sapcc
93
+
└── config.ts # new file for b2b store
94
+
```
95
+
96
+
:::tip
97
+
This approach leverages the [file-based inheritance](/guides/multistore/tooling-and-concepts/file-based-inheritance) system in Alokai, allowing you to override only what's different while inheriting everything else.
98
+
:::
99
+
100
+
## Best Practices
101
+
102
+
### 1. Use Environment Variables
103
+
104
+
Instead of creating separate configuration files for each store, leverage **environment variables** where possible. Different environment settings can dynamically configure the middleware or storefront application for each store.
105
+
106
+
This approach helps avoid duplicated files and makes your solution more modular, clean, and easy to maintain.
107
+
108
+
Let's improve our previous configuration example to use environment variables:
catalogId: 'b2cProductsCatalog', // store specific value
186
+
};
187
+
```
188
+
189
+
With this setup, the store-specific configuration will seamlessly integrate with the base configuration
190
+
191
+
## Setting Up Environment Variables for instances in Alokai Console
192
+
193
+
Every instance can have its own environment variables configured for middleware and storefront application. To find out how to provide environment variables, please check the [Console docs](/console/instance/settings/environment-variables).
194
+
195
+
For developers, working with `.env` files is straightforward:
196
+
1. Copy the `.env.example` file
197
+
2. Rename it to `.env` and customize its values for the specific store
198
+
3. The environment variables will be automatically loaded when you run the store locally
199
+
200
+
## Final Recommendations
201
+
202
+
1.**Modular Setup**: Use environment variables and file-based inheritance to avoid duplication and ensure shared code remains central.
203
+
2.**Clean Configuration Files**: Keep files minimal with overrides only for values that differ between stores.
204
+
3.**Versioned Examples**: Always provide `.env.example` templates and ensure sensitive data isn't pushed to the repository.
205
+
206
+
By following these practices, your setup will remain clean, scalable, and easy to manage, no matter how many stores or integrations you add in the future.
207
+
208
+
::card{title="Next: Different integrations in each store"icon="tabler:number-2-small"}
209
+
210
+
#description
211
+
Learn how to implement and manage different integrations across your stores.
0 commit comments