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
Multiwebsite support starts with the Elasticsearch indexing. Basically, each store has its own Elasticsearch index and should be populated separately using the [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront) tool.
8
8
9
+
:::warning
10
+
11
+
Using node indexer to enable _multistore_ feature for _Vue Storefront_ has been deprecated.
12
+
You can use _Bridge Indexer_ for the better performance and maintainability. For Magento 2, you can find it [here](https://github.com/DivanteLtd/magento2-vsbridge-indexer)
13
+
:::
14
+
9
15
The simplest script to index multi site:
10
16
11
17
```bash
@@ -102,17 +108,30 @@ The last thing is to change the `vue-storefront/config/local.json` to configure
102
108
"tax": {
103
109
"defaultCountry": "DE",
104
110
"defaultRegion": "",
105
-
"calculateServerSide": true
111
+
"sourcePriceIncludesTax": false,
112
+
"calculateServerSide": true,
113
+
"userGroupId": null,
114
+
"useOnlyDefaultUserGroupId": false,
115
+
"deprecatedPriceFieldsSupport": true,
116
+
"finalPriceIncludesTax": false
106
117
},
107
118
"i18n": {
108
-
"fullCountryName": "Germany",
109
-
"fullLanguageName": "German",
110
-
"defaultLanguage": "DE",
111
119
"defaultCountry": "DE",
120
+
"defaultLanguage": "DE",
121
+
"availableLocale": [
122
+
"de-DE"
123
+
],
112
124
"defaultLocale": "de-DE",
113
125
"currencyCode": "EUR",
114
-
"currencySign": "EUR",
115
-
"dateFormat": "HH:mm D-M-YYYY"
126
+
"currencySign": "€",
127
+
"currencyDecimal": "",
128
+
"currencyGroup": "",
129
+
"fractionDigits": 2,
130
+
"priceFormat": "{sign}{amount}",
131
+
"dateFormat": "HH:mm D/M/YYYY",
132
+
"fullCountryName": "Deutschland",
133
+
"fullLanguageName": "German",
134
+
"bundleAllStoreviewLanguages": false
116
135
}
117
136
},
118
137
"it": {
@@ -125,24 +144,41 @@ The last thing is to change the `vue-storefront/config/local.json` to configure
125
144
"index": "vue_storefront_catalog_it"
126
145
},
127
146
"tax": {
128
-
"defaultCountry": "DE",
147
+
"defaultCountry": "IT",
129
148
"defaultRegion": "",
130
-
"calculateServerSide": true
149
+
"sourcePriceIncludesTax": false,
150
+
"calculateServerSide": true,
151
+
"userGroupId": null,
152
+
"useOnlyDefaultUserGroupId": false,
153
+
"deprecatedPriceFieldsSupport": true,
154
+
"finalPriceIncludesTax": false
131
155
},
132
156
"i18n": {
133
-
"fullCountryName": "Italy",
134
-
"fullLanguageName": "Italian",
135
157
"defaultCountry": "IT",
136
158
"defaultLanguage": "IT",
159
+
"availableLocale": [
160
+
"it-IT"
161
+
],
137
162
"defaultLocale": "it-IT",
138
163
"currencyCode": "EUR",
139
-
"currencySign": "EUR",
140
-
"dateFormat": "HH:mm D-M-YYYY"
164
+
"currencySign": "€",
165
+
"currencyDecimal": "",
166
+
"currencyGroup": "",
167
+
"fractionDigits": 2,
168
+
"priceFormat": "{sign}{amount}",
169
+
"dateFormat": "HH:mm D/M/YYYY",
170
+
"fullCountryName": "Italy",
171
+
"fullLanguageName": "Italian",
172
+
"bundleAllStoreviewLanguages": false
141
173
}
142
174
}
143
175
},
144
176
```
145
177
178
+
:::tip
179
+
You can find more options available to _multistore_ features in [store view](/guide/basics/configuration.html#store-views) section of _Configuration File Explained_.
180
+
:::
181
+
146
182
After these changes, you'll have a `LanguageSwitcher` component visible on the bottom.
147
183
148
184
By default, the language / store is switched by the URL prefix:
Another option is to create a separate theme for a specific storeview. Runtime theme changes are not possible, as themes are compiled in the JS bundles by webpack during the page build process. In that case, you should run separate instances of `vue-storefront` having the proper theme set in the `config/local.json` file.
180
216
181
-
## Localized routes
217
+
## Useful _Helpers_
218
+
219
+
### How to get current store view?
220
+
221
+
Here is a helper method to get the value of current store view.
222
+
223
+
You just need to import `currentStoreView` function from `core/lib/multistore` as example follows:
`currentStoreView()` will return the object value you set in `local.json` - it should be type of StoreView or extended StoreView.
235
+
```ts
236
+
interfaceStoreView {
237
+
storeCode:string,
238
+
extend?:string,
239
+
disabled?:boolean,
240
+
storeId:any,
241
+
name?:string,
242
+
url?:string,
243
+
appendStoreCode?:boolean,
244
+
elasticsearch: {
245
+
host:string,
246
+
index:string
247
+
},
248
+
tax: {
249
+
sourcePriceIncludesTax?:boolean,
250
+
finalPriceIncludesTax?:boolean,
251
+
deprecatedPriceFieldsSupport?:boolean,
252
+
defaultCountry:string,
253
+
defaultRegion:null|string,
254
+
calculateServerSide:boolean,
255
+
userGroupId?:number,
256
+
useOnlyDefaultUserGroupId:boolean
257
+
},
258
+
i18n: {
259
+
fullCountryName:string,
260
+
fullLanguageName:string,
261
+
defaultLanguage:string,
262
+
defaultCountry:string,
263
+
defaultLocale:string,
264
+
currencyCode:string,
265
+
currencySign:string,
266
+
currencyDecimal:string,
267
+
currencyGroup:string,
268
+
fractionDigits:number,
269
+
priceFormat:string,
270
+
dateFormat:string
271
+
},
272
+
seo: {
273
+
defaultTitle:string
274
+
}
275
+
}
276
+
```
277
+
278
+
### How to remove store code from route
279
+
280
+
When you need to remove `storeCode` from route in such a case you want to route to default store by mapping fallback, use `removeStoreCodeFromRoute` as following example :
If you need to append or update `storeCode` query parameter in provided URL you can do it by calling `adjustMultistoreApiUrl` function as following example:
It will use `storeCode` query parameter from the `req` to figure out which store to use. To make it work properly you should also configure different stores in your VSF-API's config. Check this example configuration for `de` and `it` store codes:
`appendStoreCode` option of the store view configuration should be set to `true` to display store code as tip above
368
+
:::
182
369
183
-
The route switching mechanism by default works on the URL level. Please use the `localizedRoute` mixin:
370
+
:::warning
371
+
`localizedRoute` is injected to each Vue's instance so you can access it in your component with `this.localizedRoute`. You could also use it in template without additional imports.
0 commit comments