Script: Class dw.system.Site

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.

Constants

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)

Properties

allowedCurrencies : List Read Only

The allowed currencies of the current site as a collection of currency codes.

allowedLocales : List Read Only

The allowed locales of the current site as a collection of locale ID's.

allSites : List Read Only

All sites.

calendar : Calendar Read Only

A new Calendar object in the time zone of the current site.

currencyCode : String Read Only

The default currency code for the current site.

Deprecated:

Use getDefaultCurrency() method instead,

current : Site Read Only

The current site.

defaultCurrency : String Read Only

The default currency code for the current site.

defaultLocale : String Read Only

Return default locale for the site.

einsteinSiteID : String Read Only

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

The configured HTTP host name. If no host name is configured the method returns the instance hostname.

httpsHostName : String Read Only

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.

ID : String Read Only

The ID of the site.

name : String Read Only

A descriptive name for 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.

Deprecated:

This item is deprecated.

pageMetaTags : Array Read Only

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

The status of this site.

Possible values are SITE_STATUS_ONLINE, SITE_STATUS_MAINTENANCE, SITE_STATUS_PROTECTED

timezone : String Read Only

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.

Constructor Summary

This class does not have a constructor, so you cannot create it directly.

Method Summary

getAllowedCurrencies() : List

Returns the allowed currencies of the current site as a collection of currency codes.

getAllowedLocales() : List

Returns the allowed locales of the current site as a collection of locale ID's.

static getAllSites() : List

Returns all sites.

static getCalendar() : Calendar

Returns a new Calendar object in the time zone of the current site.

getCurrencyCode() : String

Returns the default currency code for the current site.

static getCurrent() : Site

Returns the current site.

getCustomPreferenceValue(name : String) : Object

Returns a custom preference value.

getDefaultCurrency() : String

Returns the default currency code for the current site.

getDefaultLocale() : String

Return default locale for the site.

getEinsteinSiteID() : String

Returns the Einstein site Id.

getHttpHostName() : String

Returns the configured HTTP host name.

getHttpsHostName() : String

Returns the configured HTTPS host name.

getID() : String

Returns the ID of the site.

getName() : String

Returns a descriptive name for the site.

getPageMetaTag(id : String) : PageMetaTag

Returns the page meta tag for the specified id.

getPageMetaTags() : Array

Returns all page meta tags, defined for this instance for which content can be generated.

getPreferences() : SitePreferences

This method returns a container of all site preferences of this site.

getStatus() : Number

Returns the status of this site.

getTimezone() : String

Returns the code for the time zone in which the storefront is running.

getTimezoneOffset() : Number

Returns time zone offset in which the storefront is running.

isOMSEnabled() : boolean

Whether oms is active in the current site.

setCustomPreferenceValue(name : String, value : Object) : void

The method sets a value for a custom preference.

Methods inherited from class Object

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

Method Detail

getAllowedCurrencies

getAllowedCurrencies() : List

Returns the allowed currencies of the current site as a collection of currency codes.

Returns:

Collection of allowed site currencies

getAllowedLocales

getAllowedLocales() : List

Returns the allowed locales of the current site as a collection of locale ID's.

Returns:

Collection if allowed site locales


getAllSites

static getAllSites() : List

Returns all sites.

Returns:

all sites for the current instance


getCalendar

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

getCurrencyCode() : String

Returns the default currency code for the current site.

Deprecated:

Use getDefaultCurrency() method instead,

Returns:

the default currency code for the current site.


getCurrent

static getCurrent() : Site

Returns the current site.

Returns:

the current site.


getCustomPreferenceValue

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.

// Method #1 var mySitePrefValue1 : String = dw.system.Site.getCurrent(). getCustomPreferenceValue("mySitePref");

// Method #2 var sitePrefs : SitePreferences = dw.system.Site.getCurrent().getPreferences(); var mySitePrefValue2 : String = sitePrefs.getCustom()["mySitePref"];

Parameters:

name - preference name.

Returns:

the preference value, or null if there is no preference with the given name.


getDefaultCurrency

getDefaultCurrency() : String

Returns the default currency code for the current site.

Returns:

the default currency code for the current site.


getDefaultLocale

getDefaultLocale() : String

Return default locale for the site.

Returns:

default locale for the site.


getEinsteinSiteID

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

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

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

getID() : String

Returns the ID of the site.

Returns:

the ID of the site.


getName

getName() : String

Returns a descriptive name for the site.

Returns:

a descriptive name for the site.


getPageMetaTag

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

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

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

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

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

getTimezoneOffset() : Number

Returns time zone offset in which the storefront is running.

Returns:

time zone offset in which the storefront is running.


isOMSEnabled

isOMSEnabled() : boolean

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.

Deprecated:

This item is deprecated.

Returns:

whether oms is active in the site


setCustomPreferenceValue

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