ePages 7.21.0 - DE_EPAGES/Shop/API/Object/Shop.pm

Package DE_EPAGES::Shop::API::Object::Shop

object interface for Shop.

Base
DE_EPAGES::Object::API::Object::Site

Functions

_importUnityTranslations
activateCurrency
activeCurrencies
activeLocaleByLanguage
addCountry
addCurrency
addLanguage
addRegion
backofficeLocales
businessHours
canInvalidatePageCache
className
countries
currencies
dbPackage
deactivateCurrency
defaultCountry
existsCountry
existsCurrency
existsLanguage
existsRegion
existsSiteLocale
exportXMLChildElements
exportableChildren
featureCurrentValue
featureIncrementValue
featureIsDirty
featureIsVisible
featureMaxValue
featureTestValue
features
formatNumber
formatter
getFavIconUrl
getLogoUrl
getShopUrl
getWebUrl
importPrefilledAttributesUnityTranslations
importUneditableAttributesUnityTranslations
infoCountry
isCurrencyActive
isTemporaryClosed
isUnity
languages
localeByLanguage
localeForLanguageByShopLocaleIDAndLanguage
processCookieLawMessage
regions
registerUnity
removeCountry
removeCurrency
removeLanguage
removeRegion
renumberCountries
sendUnityRequest
updateCountry
updateCurrency
updateSiteLocale
updateUnityShop
useMobileView

_importUnityTranslations

Imports translations in the given language for a Unity shop from the directory $ENV{'EPAGES_SHARED'}.'/Stores/Store/ShopImport/

Syntax
$Shop->_importUnityTranslations($FileNameExtension, $LanguageID);
Input
$FileNameExtension (string)
file name extension:
Translation.<Extension>Unity.xx.xml
$LanguageID (integer)
languageID

activateCurrency

Sets a currency active in the storefront.

Syntax
my $Finished = $Shop->activateCurrency($CurrencyID);
Input
$CurrencyID (char(3))
Currency identifier
Return
$Finished (int)
Returns 1 if update is finished

activeCurrencies

Returns all currencies that are usable in the storefront of the shop.

Syntax
$aCurrencyID = $Shop->activeCurrencies;
Return
$aCurrencyID (ref.array.char(3))
list of currency identifiers

activeLocaleByLanguage

Returns the first ACTIVE locale for a given language, sorted by position.

Syntax
my $LocaleID = $Shop->activeLocaleByLanguage($LanguageID);
Input
$LanguageID (int)
language id
Return
$LocaleID (string)
locale identifier

addCountry

Adds a Country to the shop.

Syntax
$Shop->addCountry($CountryID,$Position,$IsDefault);
Example
$Shop->addCountry(4,10,1);
Input
$CountryID (int)
Country identifier
$Position (int)
Position in the list
$IsDefault (int)
default country for shop

addCurrency

Adds a currency to the shop.

Syntax
$Shop->addCurrency($CurrencyID);
Example
$Shop->addCurrency('EUR');
Input
$CurrencyID (char(3))
Currency identifier

addLanguage

Adds a Language to the shop. If the shop has only one storefront language (feature Langauges=1), then the current language is removed before the new language is added. In this case also the default locale is changed.

Syntax
$Shop->addLanguage($LanguageID);
Example
$Shop->addLanguage(32);
Input
$LanguageID (int)
Language identifier
Return
$Language (object)
language object

addRegion

Adds a region to the shop.

Syntax
$Shop->addRegion($Alias);
Example
$Shop->addRegion('EU-Countries');
Input
$Alias (string)
the Alias for the Region
Return
$Region (DE_EPAGES::Shop::API::Object::Region)
region object

backofficeLocales

Returns all locales that can be used in the back-office of the shop.

Syntax
$aLocales = $Shop->backofficeLocales;
Return
$aLocales (ref.array.object)
list of SiteLocale objects

businessHours

Returns shop calendar (child BusinessHours), if not exists then the calendar will be created.

Syntax
$Calendar = $Shop->businessHours;
Return
$Calendar (object)
calendar object

canInvalidatePageCache

Return true if page cache can be updated. Default is false. If page cache should set to invalid the object has to overwrite this method.

Syntax
$Object->canInvalidatePageCache;
Return
$canInvalidate (boolean)
true if page cache can be updated

className

Returns the class name, used for DAL access.

Syntax
$ClassName = $Shop->className;
Return
$ClassName (String)
class name

countries

Returns all countries that are assigned to the shop.

Syntax
$aCountryID = $Shop->countries;
Return
$aCountryID (ref.array.cahr(3))
list of country identifiers

currencies

Returns all currencies that are assigned to the shop.

Syntax
$aCurrencyID = $Shop->currencies;
Return
$aCurrencyID (ref.array.char(3))
list of currency identifiers

dbPackage

Returns the database package, used for DAL access.

Syntax
$DbPackage = $Shop->dbPackage;
Return
$DbPackage (String)
database package name

deactivateCurrency

Sets a currency inactive in the storefront.

Syntax
my $Finished = $Shop->deactivateCurrency($CurrencyID);
Input
$CurrencyID (char(3))
Currency identifier
Return
$Finished (int)
Returns 1 if update is finished

defaultCountry

Return id of default country of the shop, or undef if no default country is set

Syntax
$Shop->defaultCountry();
Return
$CountryID (int)
CountryID

existsCountry

Asks if a Country exists for the shop.

Syntax
my $Exists = $Shop->existsCountry($CountryID);
Input
$CountryID (int)
Country identifier
Return
$Exists (boolean)
1/0 the ShopCountry exists (yes/no)

existsCurrency

Asks if a currency exists in the shop.

Syntax
my $Exists = $Shop->existsCurrency($CurrencyID);
Input
$CurrencyID (char(3))
Currency identifier
Return
$Exists (boolean)
1/0 the ShopCurrency exists (yes/no)

existsLanguage

Asks if a Language exists for the shop.

Syntax
$Exists = $Shop->existsLanguage($LanguageID);
Input
$LanguageID (int)
Language identifier
Return
$Exists (boolean)
true if the language is enabled in the shop

existsRegion

Asks if a Region exists for the shop.

Syntax
my $Exists = $Shop->existsRegion($Alias);
Input
$Alias (string)
Region alias
Return
$Exists (boolean)
1/0 the Region exists (yes/no)

existsSiteLocale

Returns true if the site supports the given locale. Returns false if the shop does not support the languageof the locale, because the number of languages per shop is restricted by a feature.

Syntax
$Exists = $Site->existsSiteLocale($LocaleID);
Example
if( $Site->existsSiteLocale('en_GB') ) { ... }
Input
$LocaleID (string)
locale id, e.g. 'en_GB'
Return
$Exists (boolean)
true if the locale is supported by the site

exportXMLChildElements

Add xml elements for children (asks each with planXMLExport to add to driver).

Syntax
$Object->exportXMLChildElements( $Driver, $hAttributes );
Input
$Driver (object)
xml export driver with support function addObject
$hAttributes (ref.hash.string)
plain attributes

exportableChildren

Don't export the folder "Languages".

Syntax
$aChildren = $Object->exportableChildren
Return
$aChildren (array ref)
children of the object

featureCurrentValue

Returns or sets the currently used value of a shop feature. The function also checks if the new value is larger than the previous value and larger than the limit of featureMaxValue for this shop. The error FeatureLimitExceeded is thrown if $NewValue > featureMaxValue && $NewValue > featureCurrentValue.

Syntax
$CurrentValue = $Shop->featureCurrentValue( $FeatureName );
$CurrentValue = $Shop->featureCurrentValue( $Feature );
$Shop->featureCurrentValue( $Feature, $NewValue );
$Shop->featureCurrentValue( $Feature, $NewValue, $AllowToExceed );
Example
if( $Shop->featureCurrentValue( 'Products' ) < $MaxValue ) { ... };
my $CountProducts = CountShopProducts( $Shop );
$Shop->featureCurrentValue( $FeatureProducts, $CountProducts );
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object
$NewValue (int)
currently used value
$AllowToExceed (boolean)
(optional, default: false) don't thow an error if the
new value exceeds the maximum allowed. Set this flag to true when
objects are deleted
Return
$CurrentValue (int)
currently used value

featureIncrementValue

Increments or decrements the currently value of a shop feature. The function also checks if the new value is larger than the previous value and larger than the limit of featureMaxValue for this shop. The error FeatureLimitExceeded is thrown if $NewValue > featureMaxValue && $NewValue > featureCurrentValue.

Syntax
$CurrentValue = $Shop->featureIncrementValue( $FeatureName, $IncValue );
$CurrentValue = $Shop->featureIncrementValue( $Feature, $IncValue );
Example
$Shop->featureIncrementValue('Products', 1);  # on insert product
$Shop->featureIncrementValue('Products', -1); # on delete product
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object
$IncValue (int)
increment value (optional 1)
Return
$CurrentValue (int)
currently used value

featureIsDirty

Returns or sets the IsDirty flag for a feature. If this flag is true, then the current value of the feature may not be corrent and should be updated by the script resetDirtyShopFeatures.pl.

Syntax
$IsDirty = $Shop->featureIsDirty( $Feature );
$IsDirty = $Shop->featureIsDirty( $FeatureName );
$Shop->featureIsDirty( $Feature, $IsDirty );
Example
$Shop->featureIsDirty( 'GallerySize', 1 );
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object
$IsDirty (int)
true if the feature current value is not up to date
Return
$IsDirty (int)
true if the feature current value is not up to date

featureIsVisible

Returns true shop feature is visible.

Syntax
$IsVisible = $Shop->featureIsVisible( $FeatureName );
$IsVisible = $Shop->featureIsVisible( $Feature );
$Shop->featureIsVisible( $Feature );
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object
Return
$IsVisible (boolean)
visible

featureMaxValue

Returns or sets the maximum value of a shop feature. It is not an error to set the featureMaxValue to a value less than featureCurrentValue.

Syntax
$MaxValue = $Shop->featureMaxValue( $FeatureName );
$MaxValue = $Shop->featureMaxValue( $Feature );
$Shop->featureMaxValue( $Feature, $NewValue, $IsVisible );
Example
if( $Shop->featureMaxValue( 'Products' ) > $CurrentValue ) { ... };
my $OldMaxValue = $Shop->featureMaxValue( $FeatureProducts );
$Shop->featureMaxValue( $FeatureProducts, $OldMaxValue + 10 );
my $NewMaxValue = $Shop->featureMaxValue( $FeatureProducts );
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object
$NewValue (int)
maximum allowed value
$IsVisible (boolean)
is visible at mbo
Return
$MaxValue (int)
maximum allowed value

featureTestValue

Throws error if feature is more used as possible.

Syntax
$Shop->featureTestValue( $FeatureName );
$Shop->featureTestValue( $Feature );
Input
$FeatureName (string)
feature name
$Feature (DE_EPAGES::Shop::API::Object::Feature)
feature object

features

Returns all features that are assigned to the shop.

Syntax
$aFeature = $Shop->features;
Return
$aFeature (ref.array.object)
list of feature objects

formatNumber

Returns the alias for this class.

Syntax
$FormNo = $Shop->formatNumber($ClassName, $Number, $Parent);
Example
$FormNo = $Shop->formatNumber('Invoice', 1234, $Order);
Input
$ClassName (string)
class name
$Number (integer)
number suffix of alias
$Parent (DE_EPAGES::Object::API::Object::Object)
parent object (optional)
Return
$NextNo (string)
new number alias suitable for given class name

formatter

Returns the money formatter for the currency.

Syntax
$Formatter = $Shop->formatter($CurrencyID);
Input
$CurrencyID (char(3))
currency code
Return
$Formatter (object)
money formatter

getFavIconUrl

retruns the absolute URL of the favicon, used to hand it over to Unity, in case there is no shop specific favicon it will return the URL of the system favicon

Syntax
$Shop->getFavIconUrl($FavIcon);
Input
$FavIcon (string)
relative path of the favicon, stored in the 'FavIcon' attribute
of the shop
Return
$FavIconURL (string)
absolute URL to the shop or system FavIcon

getLogoUrl

retruns the absolute URL of the logo, used to hand it over to Unity

Syntax
$Shop->getLogoUrl($Logo);
Input
$Logo (string)
relative path of the logo, stored in the 'Logo' attribute
of the shop
Return
$LogoURL (string)
absolute URL to the shop logo

getShopUrl

Construct the shop url of a given object dependend of the following parameters:

Syntax
$ShopUrl = $Object->getShopUrl($hParams, $hOptions, $Servlet);
Input
$hParams (ref.hash)
url get parameters; values may be strings or arrays of strings
$hOptions (ref.hash)
with following keys:
  • Type - one of 'sf', 'admin', 'mobile', 'sf/mobile',
    if type is 'sf/mobile' a .mobile will be generated if the servlet is defined and the client
    is a mobile device, otherwise a .sf url is generated; defaults to 'sf' - string
  • UseSSL - use https as protocol if SSL enabled for shop / database (optional, defaults to 0) - boolean
  • UseObjectPath - use object path rather than objectid (optional, defaults to 0) - boolean
  • AddToken - add security token or not (optional, defaults to 0) - boolean
  • Token - the security token (required AddToken is true) - String
  • AddCookies - add cookies to url or not (optional, defaults to 0) - boolean
  • Cookies - cookie values (required if AddCookies is true) - hash.ref
  • NoUTF8 - do not use utf-8 for encoding get parameters (optional, defaults to 0) - boolean
  • IsMobileServlet - is the client a mobile device or not - boolean
$Shop (object)
the current shop
Return
$url (string)
the url

getWebUrl

Construct the web url of a given object dependend of the following parameters:

Syntax
$WebUrl = $Object->getWebUrl($hParams);
Input
$hParams (hash ref)
attributes of new object
  • SSL - SSL web url - boolean
  • Section - Storefront | Mobile | Admin - string
Return
$WebUrl (string)
web url of the object

importPrefilledAttributesUnityTranslations

Imports translations that should be prefilled in the given language for a Unity shop from the files $ENV{'EPAGES_SHARED'}.'/Stores/Store/ShopImport/ Translation.PrefilledAttributesUnity.**.xml

Syntax
$Shop->importPrefilledAttributesUnityTranslations($LanguageID);
Input
$LanguageID (integer)
languageID

importUneditableAttributesUnityTranslations

Imports the uneditable translations in the given language for a Unity shop from the files $ENV{'EPAGES_SHARED'}.'/Stores/Store/ShopImport/ Translation.UneditableAttributesUnity.**.xml

Syntax
$Shop->importUneditableAttributesUnityTranslations($LanguageID);
Input
$LanguageID (integer)
languageID

infoCountry

Return information about a country of the shop.

Syntax
$Shop->infoCountry($CountryID);
Input
$CountryID (int)
Country identifier
Return
$hShopCountry (reference to hash)
with following keys:
  • ShopID - shop id (part of primary key)- int
  • CountryID - country identifier - iso num c (part of primary key)- int
  • Position - position (optional)- int
  • IsDefault - is default (optional)- int

isCurrencyActive

Asks if the currency is active in the storefront.

Syntax
my $IsActivated = $Shop->isCurrencyActive($CurrencyID);
Input
$CurrencyID (char(3))
Currency identifier
Return
$IsActivated (bit)
currency is activated at storefront

isTemporaryClosed

Returns true if the site is closed temporary. In this case all pages should be delivered with the HTTP status 503 (Service Temporarily Unavailable) to prevent search engines from caching the "shop closed" message.

Syntax
$IsClosed = $Site->isTemporaryClosed;
Return
$IsClosed (boolean)
true if site is closed

isUnity

Asks if the shop has been registered as a unity shop.

Syntax
$IsUnityShop = $Shop->isUnity();
Return
$IsUnityShop (bit)
shop is a unity one

languages

Returns all languages that are assigned to the shop.

Syntax
$aLanguageID = $Shop->languages;
Return
$aLanguageID (ref.array.int)
list of language identifier

localeByLanguage

Returns the first locale for a given language, sorted by position.

Syntax
$LocaleID = $Shop->localeByLanguage($LanguageID);
Input
$LanguageID (int)
$LanguageID
Return
$LocaleID (string)
locale identifier

localeForLanguageByShopLocaleIDAndLanguage

Returns the locale for a ShopLocaleID and language If we have "de_CH" as shop locale and add "Italian" as language this function tries to find the locale ch_IT otherwise it_IT is returned

Syntax
$LocaleID = $Shop->localeForLanguageByShopLocaleIDAndLanguage($Language);
Input
$Language (object)
$Language
Return
$LocaleID (string)
found locale identifier

processCookieLawMessage

provides a cookie law message and status if enabled

Syntax
$Shop->processCookieLawMessage;
Input
$hParams (hash ref)
content for request
$LanguageID (int)
language ID
Return
$ShowMessage (JSON object)
JSON::true : JSON::false
$Message (string)
cookie law message

regions

Returns all regions that are assigned to the shop.

Syntax
$aRegions = $Shop->regions;
Return
$aRegions (ref.array.object)
list of region objects

registerUnity

Register the shop at the Unity server. Throws UNITY_API_CALL_ERROR if this failed.

Syntax
$Shop->registerUnity;
Hook
API_BeforeCreateUnityShop
hook parameter keys :
  • Object - this object - object
  • Content - content to send to the unity API - ref.hash

removeCountry

Removes a Country from the shop.

Syntax
$Shop->removeCountry($CountryID);
Input
$CountryID (int)
Country identifier

removeCurrency

Removes a currency from the shop.

Syntax
my $Finished = $Shop->removeCurrency($CurrencyID);
Input
$CurrencyID (char(3))
Currency identifier
Return
$Finished (int)
Returns 1 if update is finished

removeLanguage

Removes a Language from the shop.

Syntax
$Shop->removeLanguage($LanguageID);
Input
$LanguageID (int)
Language identifier

removeRegion

Removes a Region from the shop.

Syntax
$Shop->removeRegion($Alias);
Input
$Alias (string)
Region alias

renumberCountries

Update the positions of countries in the shop.

Syntax
$Shop->renumberCountries();

sendUnityRequest

sends a request to the unity server with the given parameter Throws UNITY_API_CALL_ERROR if the request was not successfull.

Syntax
$Shop->sendUnityRequest($Method, $Route, $hQueryParams, $hContent, $aIgnoreCodes);
$Shop->sendUnityRequest('POST', '/shop/locale', {}, {'locale'=>'ru_RU'});
$Shop->sendUnityRequest('PATCH', '/shop', {'locale'=>'en_EN'}, {'name'=>'MyShop'});
$Shop->sendUnityRequest('DELETE', '/shop/locale', {'locale'=>'en_EN'}, {}, [400,404]);
Input
$Method (string)
request method
$Route (string)
route to object
$hQueryParams (string)
query parameters for call (optional)
$hContent (string)
payload for call (optional)
$aIgnoreCodes (ref.array)
ignore this response codes (do not produce errors)
Return
$Response (string)
JSON decoded response if method is GET otherwise undef

updateCountry

Update the position of a country in the shop or set a country default.

Syntax
my $Finished = $Shop->updateCountry($CountryID, $Position, $IsDefault);
Input
$CountryID (int)
Country identifier
$Position (int)
position in the list
$IsDefault (int)
true if a country is default
Return
$Finished (int)
Returns 1 if update is finished

updateCurrency

Update the position of the currency in the shop.

Syntax
my $Finished = $Shop->updateCurrency($CurrencyID, $Position);
Input
$CurrencyID (int)
Currency identifier
$Position (int)
position in the list
Return
$Finished (int)
Returns 1 if update is finished

updateSiteLocale

Update the position of the sitelocale in the shop.

Syntax
my $Finished = $Shop->updateSiteLocale($LocaleID, $Position);
Input
$LocaleID (int)
Locale identifier
$Position (int)
position in the list
Return
$Finished (int)
Returns 1 if update is finished

updateUnityShop

Performs a REST call to Unity in case the shop attributes have changed. This function triggers the hook 'API_BeforePatchUnityShop'.

Syntax
$Shop->updateUnityShop($hParameter);
Input
$hParams (hash ref)
content for request
$LanguageID (integer)
language id
Hook
API_BeforePatchUnityShop
hook parameter keys :
  • Object - this object - object
  • Values - new values for object - ref.hash
  • Content - content to patch to the unity API - ref.hash

useMobileView

if the feature is enabled and the shop allows mobile view

Syntax
$UseMobileView = DE_EPAGES::Object::API::Object::Site->useMobileView();
Return
$UseMobileView (boolean)
true if the mobile view should be used