Class Site
This class represents a site in Commerce Cloud Digital and provides access to several site-level configuration values which are managed from within the Business Manager. It is only possible to get a reference to the current site as determined by the current request. The static method getCurrent() returns a reference to the current site.
| Constant | Description |
|---|---|
| SITE_STATUS_MAINTENANCE: Number = 3 | Constant that represents the Site under maintenance/offline |
| SITE_STATUS_ONLINE: Number = 1 | Constant that represents the Site is Online |
| SITE_STATUS_PROTECTED: Number = 5 | Constant that represents the Site is in preview mode or online/password (protected) |
| Property | Description |
|---|---|
ID: String (read-only) | Returns the ID of the site. |
(read-only) | Whether oms is active in the current site. |
allSites: List (read-only) | Returns all sites. |
allowedCurrencies: List (read-only) | Returns the allowed currencies of the current site as a collection of currency codes. |
allowedLocales: List (read-only) | Returns the allowed locales of the current site as a collection of locale ID's. |
calendar: Calendar (read-only) | Returns a new Calendar object in the time zone of the current site. |
(read-only) | Returns the default currency code for the current site. |
current: Site (read-only) | Returns the current site. |
defaultCurrency: String (read-only) | Returns the default currency code for the current site. |
defaultLocale: String (read-only) | Return default locale for the site. |
einsteinSiteID: String (read-only) | Returns the Einstein site Id. |
httpHostName: String (read-only) | Returns the configured HTTP host name. |
httpsHostName: String (read-only) | Returns the configured HTTPS host name. |
name: String (read-only) | Returns a descriptive name for the site. |
pageMetaTags: Array (read-only) | Returns all page meta tags, defined for this instance for which content can be generated. |
preferences: SitePreferences (read-only) | This method returns a container of all site preferences of this site. |
status: Number (read-only) | Returns the status of this site. |
timezone: String (read-only) | Returns the code for the time zone in which the storefront is running. |
timezoneOffset: Number (read-only) | Returns time zone offset in which the storefront is running. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| static getAllSites() | Returns all sites. |
| getAllowedCurrencies() | Returns the allowed currencies of the current site as a collection of currency codes. |
| getAllowedLocales() | Returns the allowed locales of the current site as a collection of locale ID's. |
| static getCalendar() | Returns a new Calendar object in the time zone of the current site. |
| Returns the default currency code for the current site. | |
| static getCurrent() | Returns the current site. |
| getCustomPreferenceValue(String) | Returns a custom preference value. |
| getDefaultCurrency() | Returns the default currency code for the current site. |
| getDefaultLocale() | Return default locale for the site. |
| getEinsteinSiteID() | Returns the Einstein site Id. |
| getHttpHostName() | Returns the configured HTTP host name. |
| getHttpsHostName() | Returns the configured HTTPS host name. |
| getID() | Returns the ID of the site. |
| getName() | Returns a descriptive name for the site. |
| getPageMetaTag(String) | Returns the page meta tag for the specified id. |
| getPageMetaTags() | Returns all page meta tags, defined for this instance for which content can be generated. |
| getPreferences() | This method returns a container of all site preferences of this site. |
| getStatus() | Returns the status of this site. |
| getTimezone() | Returns the code for the time zone in which the storefront is running. |
| getTimezoneOffset() | Returns time zone offset in which the storefront is running. |
| Whether oms is active in the current site. | |
| setCustomPreferenceValue(String, Object) | The method sets a value for a custom preference. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- SITE_STATUS_MAINTENANCE: Number = 3
Constant that represents the Site under maintenance/offline
- SITE_STATUS_ONLINE: Number = 1
Constant that represents the Site is Online
- SITE_STATUS_PROTECTED: Number = 5
Constant that represents the Site is in preview mode or online/password (protected)
- ID: String
(read-only) Returns the ID of the site.
OMSEnabled: Boolean(read-only)Whether oms is active in the current site. This depends on a general property which states whether oms is active for the server, and a site-dependent preference whether oms is available for the current site.
- allSites: List
(read-only) Returns all sites.
- allowedCurrencies: List
(read-only) Returns the allowed currencies of the current site as a collection of currency codes.
- allowedLocales: List
(read-only) Returns the allowed locales of the current site as a collection of locale ID's.
- calendar: Calendar
(read-only) Returns a new Calendar object in the time zone of the current site.
currencyCode: String(read-only)Returns the default currency code for the current site.
Deprecated:
Use getDefaultCurrency() method instead,
- current: Site
(read-only) Returns the current site.
- defaultCurrency: String
(read-only) Returns the default currency code for the current site.
- defaultLocale: String
(read-only) Return default locale for the site.
- einsteinSiteID: String
(read-only) Returns the Einstein site Id. Typically this is a concatenation of the realm, underscore character and the site id. It can be overwritten by support users to help with realm moves to continue using the Einstein data from the old realm. Used when making calls to the Einstein APIs.
- httpHostName: String
(read-only) Returns the configured HTTP host name. If no host name is configured the method returns the instance hostname.
- httpsHostName: String
(read-only) Returns the configured HTTPS host name. If no host name is configured the method returns the HTTP host name or the instance hostname, if that is not configured as well.
- name: String
(read-only) Returns a descriptive name for the site.
- pageMetaTags: Array
(read-only) Returns all page meta tags, defined for this instance for which content can be generated.
The meta tag content is generated based on the home page meta tag context and rules. The rules are obtained from the current repository domain.
- preferences: SitePreferences
(read-only) This method returns a container of all site preferences of this site.
- status: Number
(read-only) Returns the status of this site.
Possible values are SITE_STATUS_ONLINE, SITE_STATUS_MAINTENANCE, SITE_STATUS_PROTECTED
- timezone: String
(read-only) Returns the code for the time zone in which the storefront is running.
- timezoneOffset: Number
(read-only) Returns time zone offset in which the storefront is running.
- static getAllSites(): List
Returns all sites.
Returns:
- all sites for the current instance
- getAllowedCurrencies(): List
Returns the allowed currencies of the current site as a collection of currency codes.
Returns:
- Collection of allowed site currencies
- getAllowedLocales(): List
Returns the allowed locales of the current site as a collection of locale ID's.
Returns:
- Collection if allowed site locales
- static getCalendar(): Calendar
Returns a new Calendar object in the time zone of the current site.
Returns:
- the Calendar object in the time zone of the current site.
getCurrencyCode(): StringReturns the default currency code for the current site.
Returns:
- the default currency code for the current site.
Deprecated:
Use getDefaultCurrency() method instead,
- static getCurrent(): Site
Returns the current site.
Returns:
- the current site.
- getCustomPreferenceValue(name: String): Object
Returns a custom preference value. If the preference does not exist the method returns null. This method is simply a shortcut method for accessing the value for a custom attribute defined on the SitePreferences object.
Parameters:
- name - preference name.
Returns:
- the preference value, or null if there is no preference with the given name.
- getDefaultCurrency(): String
Returns the default currency code for the current site.
Returns:
- the default currency code for the current site.
- getDefaultLocale(): String
Return default locale for the site.
Returns:
- default locale for the site.
- getEinsteinSiteID(): String
Returns the Einstein site Id. Typically this is a concatenation of the realm, underscore character and the site id. It can be overwritten by support users to help with realm moves to continue using the Einstein data from the old realm. Used when making calls to the Einstein APIs.
Returns:
- the Einstein site Id
- getHttpHostName(): String
Returns the configured HTTP host name. If no host name is configured the method returns the instance hostname.
Returns:
- the configured HTTP host name or if it is not set the instance hostname.
- getHttpsHostName(): String
Returns the configured HTTPS host name. If no host name is configured the method returns the HTTP host name or the instance hostname, if that is not configured as well.
Returns:
- the configured HTTPS host name or HTTP host name or the instance hostname.
- getID(): String
Returns the ID of the site.
Returns:
- the ID of the site.
- getName(): String
Returns a descriptive name for the site.
Returns:
- a descriptive name for the site.
- getPageMetaTag(id: String): PageMetaTag
Returns the page meta tag for the specified id.
The meta tag content is generated based on the home page meta tag context and rule. The rule is obtained from the current repository domain.
Null will be returned if the meta tag is undefined on the current instance, or if no rule can be found for the current context, or if the rule resolves to an empty string.
Parameters:
- id - the ID to get the page meta tag for
Returns:
- page meta tag containing content generated based on rules
- getPageMetaTags(): Array
Returns all page meta tags, defined for this instance for which content can be generated.
The meta tag content is generated based on the home page meta tag context and rules. The rules are obtained from the current repository domain.
Returns:
- page meta tags defined for this instance, containing content generated based on rules
- getPreferences(): SitePreferences
This method returns a container of all site preferences of this site.
Returns:
- a preferences object containing all system and custom site preferences of this site
- getStatus(): Number
Returns the status of this site.
Possible values are SITE_STATUS_ONLINE, SITE_STATUS_MAINTENANCE, SITE_STATUS_PROTECTED
Returns:
- Status of the this site.
- getTimezone(): String
Returns the code for the time zone in which the storefront is running.
Returns:
- time zone code in which the storefront is running.
- getTimezoneOffset(): Number
Returns time zone offset in which the storefront is running.
Returns:
- time zone offset in which the storefront is running.
isOMSEnabled(): BooleanWhether oms is active in the current site. This depends on a general property which states whether oms is active for the server, and a site-dependent preference whether oms is available for the current site.
Returns:
- whether oms is active in the site
- setCustomPreferenceValue(name: String, value: Object): void
The method sets a value for a custom preference. The type of the value must match with the declared type of the preference definition.
Parameters:
- name - name of the preference
- value - new value for the preference