ePages 7.27.0 - DE_EPAGES/Object/API/Object/Site.pm

Package DE_EPAGES::Object::API::Object::Site

object interface for Site.

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

Functions

addLocale
backofficeLocales
className
clearDeletedObjects
clearPageCache
clearUpdatedObjects
currentDate
dbPackage
deleteFiles
existsLocale
existsSiteLocale
filePath
findCreatedObjects
findUpdatedObjects
getCreatedObjects
getDeletedObjects
getSite
getUpdatedObjects
insertIntoPoolDB
invalidatePageCache
isTemporaryClosed
loadObject
loadObjectByGuid
loadObjects
loadObjectsByGuid
removeLocale
siteLocale
units
useMobileView

addLocale

Adds a storefront locale to the site. Use $Site->get('SiteLocales') to get a list of all storefront locales.

Syntax
$SiteLocale = $Site->addLocale($LocaleID);
Example
$SiteLocale = $Site->addLocale('de_DE');
Input
$LocaleID (string)
Locale identifier
Return
$SiteLocale (object)
SiteLocale object

backofficeLocales

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

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

className

Returns the class name, used for DAL access.

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

clearDeletedObjects

Deletes information about objects in the site of a given type that have been deleted before a given date, for example which products have been deleted more than 2 weeks ago.

Syntax
$Site->clearDeletedObjects( $ClassName, $DeletedBefore );
Input
$ClassName (string)
class name, for example 'Product'
$DeletedBefore (DateTime)
date and time

clearPageCache

Clears the page cache of the complete site.

Syntax
$Shop->clearPageCache();

clearUpdatedObjects

Deletes information about updated objects in the site of a given profile.

Syntax
$Site->clearUpdatedObjects( $Profile, $UpdatedBefore );
Input
$Profile (DE_EPAGES::Object::API::Object::LastUpdateProfile)
profile object
$UpdatedBefore (DateTime)
date and time

currentDate

Returns the current date in the time zone of the site with time set to midnight (0:00:00).

Syntax
$Date = DE_EPAGES::Object::API::Object::Site->currentDate();
Return
$Date (object)
DateTime object with the current Site date

dbPackage

Returns the database package, used for DAL access.

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

deleteFiles

Deletes the directories PublicPath, PrivatePath.

Syntax
$Object->deleteFiles;

existsLocale

Returns true if the locale is $LocaleID is a storefront locale of the site.

Syntax
$exists = $Site->existsLocale($LocaleID);
Example
$exists = $Site->existsLocale('de_DE');
Input
$LocaleID (string)
Locale identifier
Return
$exists (boolean)
true if locale exists in site

existsSiteLocale

Returns true if the site supports the given locale.

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

filePath

Call DE_EPAGES::Core::API::File::ConvertPathChars with site 'Alias' and parent of site.

Syntax
$Path = $Site->filePath;
Return
$Path (string)
relative file path

findCreatedObjects

Returns information about objects of given class/subclass in the site that have been created after a given date

Syntax
$Iterator = $Site->findCreatedObjects( $Class, $CreatedAfter );
§exmple       $Iterator = $Shop->findCreatedObjects( $Shop->get('ProductClass'), $Created );
Input
$Class (object)
site related class
$CreatedAfter (DateTime)
date and time
Return
$Iterator (iterator of hashes)
iterator over hash references with following keys:
  • ObjectID - object id - int
  • CreatedOn - Date and time of creation of an object - datetime

findUpdatedObjects

Returns information about objects in the site that have been updated regarding a LastUpdateProfile after a given date

Syntax
$Iterator = $Site->findUpdatedObjects( $Profile, $UpdatedAfter );
Input
$Profile (DE_EPAGES::Object::API::Object::LastUpdateProfile)
profile object
$UpdatedAfter (DateTime)
date and time
Return
$Iterator (iterator of hashes)
iterator over hash references with following keys:
  • ObjectID - object id - int
  • LastUpdatedOn - Date and time of the update on an object - datetime

getCreatedObjects

Returns objects of given class/subclass in the site that have been created after a given date

Syntax
$Iterator = $Site->getCreatedObjects( $Class, $CreatedAfter );
§exmple       $Iterator = $Shop->getCreatedObjects( $Shop->get('ProductClass'), $Created );
Input
$Class (object)
site related class
$CreatedAfter (DateTime)
date and time
Return
$Iterator (iterator of hashes)
iterator over hash references with following keys:
  • Object - object - object
  • CreatedOn - Date and time of creation of an object - datetime

getDeletedObjects

Returns information about objects in the site of a given type that have been deleted after a given date, for example which products have been deleted in a shop since last week.

Syntax
$ahDeletedObjects= $Site->getDeletedObjects( $ClassName, $DeletedAfter );
Input
$ClassName (string)
class name, for example 'Product'
$DeletedAfter (DateTime)
date and time
Return
$Iterator (iterator of hashes)
iterator over hash references with following keys:
  • GUID - GUID of the deleted object (primary key)- varchar(36)
  • PathFromSite - Object Path relative to the object site. - varchar(1000)
  • DeletedOn - Date and time of the deletion on an object - datetime

getSite

Returns the site of an object. In this case returns the object itself.

Syntax
$Site = $Object->getSite;
Return
$Site (DE_EPAGES::Object::API::Object::Site)
site object

getUpdatedObjects

Returns objects in the site that have been updated regarding a LastUpdateProfile after a given date

Syntax
$Iterator = $Site->getUpdatedObjects( $Profile, $UpdatedAfter );
Input
$Profile (DE_EPAGES::Object::API::Object::LastUpdateProfile)
profile object
$UpdatedAfter (DateTime)
date and time
Return
$Iterator (iterator of hashes)
iterator over hash references with following keys:
  • Object - object - object
  • LastUpdatedOn - Date and time of the update on an object - datetime

insertIntoPoolDB

Insert this object in to the pooldb.

Syntax
$Site->insertIntoPoolDB();

invalidatePageCache

invalidates the page cache, use clearPageCache to clear it.

Syntax
$Shop->invalidatePageCache();

isTemporaryClosed

This method should be overwritten. Otherwise it returns always 0. That means the site is open. 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

loadObject

Loads an object by object id. Verifies that the object belongs to the given class and site.

Syntax
$Object = $Site->loadObject( $ObjectID, $Class );
$Object = $Site->loadObject( $ObjectID, $ClassName );
$Object = $Site->loadObject( $ObjectID, $Class, $hFlags );
$Object = $Site->loadObject( $ObjectID, $ClassName, $hFlags );
Example
my $ProductID = $Servlet->form->value('ProductID');
my $Object = $Shop->loadObject( $ProductID, 'Product' );
my $Unit = $Shop->loadObject( $UnitID, 'UnitOfMeasurement', { AllowSystemSite => 1 } );
Input
$ObjectID (int)
object id
$Class (DE_EPAGES::Object::API::Object::Class)
expected class of the object
$ClassName (string)
name of the expected class of the object
$hFlags (ref. hash;)
(optional),
  • AllowSystemSite - the site of $Object may also be the System object - boolean
Return
$Object (DE_EPAGES::Object::API::Object::Object)
object

loadObjectByGuid

Loads an object by GUID. Verifies that the object belongs to the given class and site.

Syntax
$Object = $Site->loadObjectByGuid( $GUID, $Class );
$Object = $Site->loadObjectByGuid( $GUID, $ClassName );
$Object = $Site->loadObjectByGuid( $GUID, $Class, $hFlags );
$Object = $Site->loadObjectByGuid( $GUID, $ClassName, $hFlags );
Example
my $ProductGUID = $Servlet->form->value('ProductGUID');
my $Object = $Shop->loadObject( $ProductGUID, 'Product' );
my $Unit = $Shop->loadObject( $UnitGUID, 'UnitOfMeasurement', { AllowSystemSite => 1 } );
Input
$GUID (string)
object GUID
$Class (DE_EPAGES::Object::API::Object::Class)
expected class of the object
$ClassName (string)
name of the expected class of the object
$hFlags (ref. hash;)
(optional),
  • AllowSystemSite - the site of $Object may also be the System object - boolean
Return
$Object (DE_EPAGES::Object::API::Object::Object)
object

loadObjects

Loads a list of objects by object ids. Verifies that the objects belongs to the given class and site.

Syntax
$aObjects = $Site->loadObjects( $aObjectIDs, $Class );
$aObjects = $Site->loadObjects( $aObjectIDs, $ClassName );
$aObjects = $Site->loadObjects( $aObjectIDs, $Class, $hFlags );
$aObjects = $Site->loadObjects( $aObjectIDs, $ClassName, $hFlags );
Example
my @ProductIDs = $Servlet->form->value('ProductID');
my $aProducts = $Shop->loadObjects( \@ProductIDs, 'Product' );
Input
$aObjectIDs (ref.array.int)
list of object ids
$Class (DE_EPAGES::Object::API::Object::Class)
expected class of the objects
$ClassName (string)
name of the expected class of the objects
$hFlags (ref. hash;)
(optional), see loadObject
Return
$aObjects (ref.array.DE_EPAGES::Object::API::Object::Object)
list of objects

loadObjectsByGuid

Loads a list of objects by GUID. Verifies that the objects belongs to the given class and site.

Syntax
$aObjects = $Site->loadObjectsByGuid( $aGUIDs, $Class );
$aObjects = $Site->loadObjectsByGuid( $aGUIDs, $ClassName );
$aObjects = $Site->loadObjectsByGuid( $aGUIDs, $Class, $hFlags );
$aObjects = $Site->loadObjectsByGuid( $aGUIDs, $ClassName, $hFlags );
Example
my @ProductGUID = $Servlet->form->value('ProductGUID');
my $aProducts = $Shop->loadObjectsByGuid( \@ProductGUIDs, 'Product' );
Input
$aGUIDs (ref.array.int)
list of GUIDs
$Class (DE_EPAGES::Object::API::Object::Class)
expected class of the objects
$ClassName (string)
name of the expected class of the objects
$hFlags (ref. hash;)
(optional), see loadObject
Return
$aObjects (ref.array.DE_EPAGES::Object::API::Object::Object)
list of objects

removeLocale

Removes a storefront locale from the site.

Syntax
$Site->removeLocale($LocaleID);
Example
$Site->removeLocale('de_DE');
Input
$LocaleID (string)
Locale identifier

siteLocale

Returns locale object with given locale identifier.

Syntax
$Locale = $Site->siteLocale($LocaleID);
Example
$Site->siteLocale('en_GB')->roundMoney($amount, $CurrencyID);
Input
$LocaleID (string)
locale id, e.g. 'en_GB'
Return
$Locale (object)
supported locale of site

units

Returns a list of all units of measurements that are available in the site.

Syntax
$aUnits = $Site->units;
Return
$aUnits (ref.array.object)
units of measurements (class UnitOfMeasurement)

useMobileView

if the site allows mobile view

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