Skip to content

Stores ​

Type
Class
Namespace
craft\commerce\services
Inherits
craft\commerce\services\Stores » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
5.0.0

Stores service.

View source

Public Properties ​

PropertyDescription
allSiteStores\Illuminate\Support\Collection<\craft\commerce\models\SiteStore>
allStores\Illuminate\Support\Collection
behaviorsyii\base\Behavior – List of behaviors attached to this component.
currentStorecraft\commerce\models\Store – The current store
primaryStorecraft\commerce\models\Store
siteIdsAvailableForAssignmentToNewStoresarray

allSiteStores ​

Type
\Illuminate\Support\Collection<\craft\commerce\models\SiteStore>
Default value
null
Access
Read-only

View source

allStores ​

Type
\Illuminate\Support\Collection
Default value
null

View source

currentStore ​

Type
craft\commerce\models\Store
Default value
null
Access
Read-only

The current store

View source

primaryStore ​

Type
craft\commerce\models\Store
Default value
null

View source

siteIdsAvailableForAssignmentToNewStores ​

Type
array
Default value
null
Access
Read-only

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
afterDeleteCraftSiteHandler()
afterSaveCraftSiteHandler()
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
deleteStore()
deleteStoreById()
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getAllSiteStores()
getAllSitesForStore()
getAllStores()
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getCurrentStore()Returns the current store.
getPrimaryStore()Returns the primary store.
getSiteIdsAvailableForAssignmentToNewStores()Returns sites that are assigned to more than one store assigned, so that other new stores can use them.
getStoreByHandle()
getStoreById()
getStoreBySiteId()
getStoreByUid()
getStoresByUserId()Returns a collections of stores that are available to a user.
handleChangedSiteStore()Handle site store mapping change.
handleChangedStore()Handle store status change.
handleDeletedSiteStore()Handle a deleted Store.
handleDeletedStore()Handle a deleted Store.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
refreshStores()Refresh the status of all stores based on the DB data.
reorderStores()
saveSiteStore()
saveStore()Saves a store.
trigger()Triggers an event.

afterDeleteCraftSiteHandler() ​

View source

Arguments ​

Returns ​

void

Throws ​

afterSaveCraftSiteHandler() ​

View source

Arguments ​

Returns ​

void

Throws ​

deleteStore() ​

View source

Arguments ​

Returns ​

boolean

Throws ​

deleteStoreById() ​

View source

Arguments ​

Returns ​

boolean

Throws ​

getAllSiteStores() ​

View source

Returns ​

\Illuminate\Support\Collection<\craft\commerce\models\SiteStore>

getAllSitesForStore() ​

View source

Arguments ​

Returns ​

\Illuminate\Support\Collection<\craft\models\Site>

getAllStores() ​

View source

Returns ​

\Illuminate\Support\Collection<\craft\commerce\models\Store>

getCurrentStore() ​

Returns the current store.

View source

Returns ​

craft\commerce\models\Store – The current store

Throws ​

getPrimaryStore() ​

Returns the primary store.

View source

Returns ​

craft\commerce\models\Store, null

getSiteIdsAvailableForAssignmentToNewStores() ​

Returns sites that are assigned to more than one store assigned, so that other new stores can use them.

View source

Returns ​

array

getStoreByHandle() ​

View source

Arguments ​

Returns ​

craft\commerce\models\Store, null

getStoreById() ​

View source

Arguments ​

Returns ​

craft\commerce\models\Store, null

getStoreBySiteId() ​

View source

Arguments ​

Returns ​

craft\commerce\models\Store, null

getStoreByUid() ​

View source

Arguments ​

Returns ​

craft\commerce\models\Store, null

getStoresByUserId() ​

Returns a collections of stores that are available to a user.

View source

Arguments ​

Returns ​

\Illuminate\Support\Collection<\craft\commerce\models\Store>

Throws ​

handleChangedSiteStore() ​

Handle site store mapping change.

View source

Arguments ​

Returns ​

void

Throws ​

handleChangedStore() ​

Handle store status change.

View source

Arguments ​

Returns ​

void

Throws ​

handleDeletedSiteStore() ​

Handle a deleted Store.

View source

Arguments ​

Throws ​

handleDeletedStore() ​

Handle a deleted Store.

View source

Arguments ​

Throws ​

refreshStores() ​

Refresh the status of all stores based on the DB data.

View source

Returns ​

void

reorderStores() ​

View source

Arguments ​

Returns ​

boolean

Throws ​

saveSiteStore() ​

View source

Arguments ​

Returns ​

boolean

Throws ​

saveStore() ​

Saves a store.

View source

Arguments ​

Returns ​

boolean

Throws ​

Constants ​

ConstantDescription
CONFIG_SITESTORES_KEYThe project config path to site stores data
CONFIG_STORES_KEYThe project config path to stores data

Events ​

EVENT_AFTER_DELETE_STORE ​

Type
craft\commerce\events\DeleteStoreEvent

The event that is triggered after a store is deleted


EVENT_AFTER_SAVE_STORE ​

Type
craft\commerce\events\StoreEvent

The event that is triggered after a store is saved.


EVENT_BEFORE_APPLY_STORE_DELETE ​

Type
craft\commerce\events\DeleteStoreEvent

The event that is triggered before a store delete is applied to the database.


EVENT_BEFORE_DELETE_STORE ​

Type
craft\commerce\events\DeleteStoreEvent

The event that is triggered before a site is deleted.

You may set craft\events\CancelableEvent::$isValid to false to prevent the site from getting deleted.


EVENT_BEFORE_SAVE_STORE ​

Type
craft\commerce\events\StoreEvent

The event that is triggered before a store is saved.