SAP Spartacus的site context配置
发布日期:2021-06-30 14:39:48 浏览次数:3 分类:技术文章

本文共 2012 字,大约阅读时间需要 6 分钟。

https://github.com/SAP/spartacus-docs/blob/901d0521dcf4668e2ddc5982947268becd0e66dd/_pages/dev/context-configuration.md

每个CMS site都有一个自己的上下文:

  • base site ID,
  • allowed languages and default language,
  • allowed currencies and default currency.
  • configuration of persistence of above attributes in the URL

静态上下文配置

You can configure your application by defining context properties, such as base site, language, and currency. When you append the values of these properties to the storefront URL, the storefront is configured based on these values.

配置代码如下:

export const b2cFeature: FeatureEnvironment = {
imports: [ B2cStorefrontModule.withConfig({
context: {
urlParameters: ['baseSite', 'language', 'currency'], baseSite: [ 'electronics-spa', 'electronics', 'apparel-de', 'apparel-uk', 'apparel-uk-spa', ], },

For example, when you access https://localhost:4200/electronics-spa/en/USD/, the application loads the electronics-spa base site, sets the site language to English (en), and sets the currency to US dollars (USD).

The context properties also set the default values for the language and currency drop-down lists, which you can use to change the context of the storefront dynamically.

Context属性在app.module.ts里定义:

context: {
baseSite: ['electronics-spa'], urlParameters: ['baseSite', 'language', 'currency'] },

urlparameter的顺序可以自己调:

context: {
baseSite: [ 'electronics-spa', //Selected by default because it is the first element in the list 'electronics', ], language: [ 'en' ], currency: [ 'USD' ], urlParameters: ['baseSite', 'language', 'currency'] },

You can change the structure of the context in the URL by changing the order of the elements in the urlParameters property. For example, if you change the urlParameters property to urlParameters: [‘currency’, ‘language’, ‘baseSite’], then the URL becomes https://localhost:4200/USD/en/electronics-spa/

转载地址:https://jerry.blog.csdn.net/article/details/111275907 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:SAP Spartacus的Structured data
下一篇:SAP Commerce的Runtime Attributes

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月25日 09时50分07秒