Constants

CONTEXT_SHOP

CONTEXT_SHOP

There are 3 kinds of shop context : shop, group shop and general

CONTEXT_GROUP

CONTEXT_GROUP

CONTEXT_ALL

CONTEXT_ALL

SHARE_CUSTOMER

SHARE_CUSTOMER

Some data can be shared between shops, like customers or orders

SHARE_ORDER

SHARE_ORDER

SHARE_STOCK

SHARE_STOCK

Properties

$id_shop_group

$id_shop_group : integer

Type

integer — ID of shop group

$id_category

$id_category : integer

Type

integer — ID of shop category

$id_theme

$id_theme : integer

Type

integer — ID of shop theme

$name

$name : string

Type

string — Shop name

$active

$active : 

Type

$deleted

$deleted : 

Type

$theme_name

$theme_name : string

Type

string — Shop theme name (read only)

$theme_directory

$theme_directory : string

Type

string — Shop theme directory (read only)

$physical_uri

$physical_uri : string

Type

string — Physical uri of main url (read only)

$virtual_uri

$virtual_uri : string

Type

string — Virtual uri of main url (read only)

$domain

$domain : string

Type

string — Domain of main url (read only)

$domain_ssl

$domain_ssl : string

Type

string — Domain SSL of main url (read only)

$definition

$definition : 

Type

$group

$group : \ShopGroup

Type

\ShopGroup — Shop group object

$shops

$shops : array

Type

array — List of shops cached

$asso_tables

$asso_tables : 

Type

$id_shop_default_tables

$id_shop_default_tables : 

Type

$initialized

$initialized : 

Type

$webserviceParameters

$webserviceParameters : 

Type

$context

$context : integer

Type

integer — Store the current context of shop (CONTEXT_ALL, CONTEXT_GROUP, CONTEXT_SHOP)

$context_id_shop

$context_id_shop : integer

Type

integer — ID shop in the current context (will be empty if context is not CONTEXT_SHOP)

$context_id_shop_group

$context_id_shop_group : integer

Type

integer — ID shop group in the current context (will be empty if context is CONTEXT_ALL)

Methods

__construct()

__construct(integer  $id = null, integer  $id_lang = null, integer  $id_shop = null) 

On shop instance, get its theme and URL data too

Parameters

integer $id
integer $id_lang
integer $id_shop

setUrl()

setUrl() 

add()

add(boolean  $autodate = true, boolean  $null_values = false) : boolean

Add a shop, and clear the cache

Parameters

boolean $autodate
boolean $null_values

Returns

boolean

associateSuperAdmins()

associateSuperAdmins() 

delete()

delete() : boolean

Remove a shop only if it has no dependencies, and remove its associations

Returns

boolean

hasDependency()

hasDependency(integer  $id_shop) : boolean

Detect dependency with customer or orders

Parameters

integer $id_shop

Returns

boolean

initialize()

initialize() : \Shop

Find the shop from current domain / uri and get an instance of this shop if INSTALL_VERSION is defined, will return an empty shop object

Returns

\Shop

getAddress()

getAddress() : \Address

Returns

\Address —

the current shop address

getTheme()

getTheme() : string

Get shop theme name

Returns

string

getBaseURI()

getBaseURI() : string

Get shop URI

Returns

string

getBaseURL()

getBaseURL() : string

Get shop URL

Returns

string

getGroup()

getGroup() : \ShopGroup

Get group of current shop

Returns

\ShopGroup

getCategory()

getCategory() : integer

Get root category of current shop

Returns

integer

getUrls()

getUrls() : array

Get list of shop's urls

Returns

array

isDefaultShop()

isDefaultShop() : boolean

Check if current shop ID is the same as default shop in configuration

Returns

boolean

getAssoTable()

getAssoTable(  $table) : array

Get the associated table if available

Parameters

$table

Returns

array

checkIdShopDefault()

checkIdShopDefault(  $table) : boolean

check if the table has an id_shop_default

Parameters

$table

Returns

boolean

getAssoTables()

getAssoTables() : array

Get list of associated tables to shop

Returns

array

addTableAssociation()

addTableAssociation(string  $table_name, array  $table_details) : boolean

Add table associated to shop

Parameters

string $table_name
array $table_details

Returns

boolean

isTableAssociated()

isTableAssociated(string  $table) : boolean

Check if given table is associated to shop

Parameters

string $table

Returns

boolean

cacheShops()

cacheShops(boolean  $refresh = false) 

Load list of groups and shops, and cache it

Parameters

boolean $refresh

getCompleteListOfShopsID()

getCompleteListOfShopsID() 

getShops()

getShops(boolean  $active = true, integer  $id_shop_group = null, boolean  $get_as_list_id = false) : array

Get shops list

Parameters

boolean $active
integer $id_shop_group
boolean $get_as_list_id

Returns

array

getUrlsSharedCart()

getUrlsSharedCart() 

getShopsCollection()

getShopsCollection(boolean  $active = true, integer  $id_shop_group = null) : \PrestaShopCollection

Get a collection of shops

Parameters

boolean $active
integer $id_shop_group

Returns

\PrestaShopCollection —

Collection of Shop

getShop()

getShop(integer  $shop_id) : array

Return some informations cached for one shop

Parameters

integer $shop_id

Returns

array

getIdByName()

getIdByName(string  $name) : integer

Return a shop ID from shop name

Parameters

string $name

Returns

integer

getTotalShops()

getTotalShops(boolean  $active = true, integer  $id_shop_group = null) : integer

Parameters

boolean $active
integer $id_shop_group

Returns

integer —

Total of shops

getGroupFromShop()

getGroupFromShop(integer  $shop_id,   $as_id = true) : integer

Retrieve group ID of a shop

Parameters

integer $shop_id

Shop ID

$as_id

Returns

integer —

Group ID

getSharedShops()

getSharedShops(integer  $shop_id, integer  $type) : array

If the shop group has the option $type activated, get all shops ID of this group, else get current shop ID

Parameters

integer $shop_id
integer $type

Shop::SHARE_CUSTOMER | Shop::SHARE_ORDER

Returns

array

getContextListShopID()

getContextListShopID(string  $share = false) : array

Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID)

Parameters

string $share

If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value

Returns

array

getShopById()

getShopById(integer  $id, string  $identifier, string  $table) : array

Return the list of shop by id

Parameters

integer $id
string $identifier
string $table

Returns

array

setContext()

setContext(integer  $type, integer  $id = null) 

Change the current shop context

Parameters

integer $type

Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP

integer $id

ID shop if CONTEXT_SHOP or id shop group if CONTEXT_GROUP

getContext()

getContext() : integer

Get current context of shop

Returns

integer

getContextShopID()

getContextShopID(  $null_value_without_multishop = false) : integer

Get current ID of shop if context is CONTEXT_SHOP

Parameters

$null_value_without_multishop

Returns

integer

getContextShopGroupID()

getContextShopGroupID(  $null_value_without_multishop = false) : integer

Get current ID of shop group if context is CONTEXT_SHOP or CONTEXT_GROUP

Parameters

$null_value_without_multishop

Returns

integer

getContextShopGroup()

getContextShopGroup() 

addSqlRestriction()

addSqlRestriction(integer  $share = false, string  $alias = null) 

Add an sql restriction for shops fields

Parameters

integer $share

If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value

string $alias

addSqlAssociation()

addSqlAssociation(string  $table, string  $alias, boolean  $inner_join = true, string  $on = null,   $force_not_default = false) : string

Add an SQL JOIN in query between a table and its associated table in multishop

Parameters

string $table

Table name (E.g. product, module, etc.)

string $alias

Alias of table

boolean $inner_join

Use or not INNER JOIN

string $on
$force_not_default

Returns

string

addSqlRestrictionOnLang()

addSqlRestrictionOnLang(string  $alias = null,   $id_shop = null) : string

Add a restriction on id_shop for multishop lang table

Parameters

string $alias
$id_shop

Returns

string

getTree()

getTree() : array

Get all groups and associated shops as subarrays

Returns

array

isFeatureActive()

isFeatureActive() : boolean

Returns

boolean —

Return true if multishop feature is active and at last 2 shops have been created

copyShopData()

copyShopData(  $old_id,   $tables_import = false,   $deleted = false) 

Parameters

$old_id
$tables_import
$deleted

getCategories()

getCategories(integer  $id,   $only_id = true) : array

Parameters

integer $id
$only_id

Returns

array

getCurrentShop()

getCurrentShop() 

getEntityIds()

getEntityIds(string  $entity, integer  $id_shop,   $active = false,   $delete = false) : array|boolean

Parameters

string $entity
integer $id_shop
$active
$delete

Returns

array|boolean

init()

init() 

Initialize an array with all the multistore associations in the database