Overview
TheStorefrontSession facade helps manage session-bound resources that a storefront typically needs, such as the active channel, currency, customer, and customer groups.
initChannel(), initCustomerGroups(), initCurrency(), and initCustomer() to restore any previously set values from the session or fall back to defaults.
Channels
Initialize the Channel
This will set the channel based on what has been previously stored in the session, otherwise it will use the default channel.This is automatically called when the facade is resolved.
Set the Channel
setChannel method accepts a Channel model instance. The channel’s handle is stored in the session so it can be restored on subsequent requests.
Get the Channel
Returns the currently activeChannel model.
Customer Groups
Initialize the Customer Groups
This will set the customer groups based on what has been previously stored in the session, otherwise it will use the default customer group.This is automatically called when the facade is resolved.
Set the Customer Groups
Get the Customer Groups
Returns aCollection of CustomerGroup models.
Reset the Customer Groups
Clears the customer groups from the session and resets the collection to empty.Customer
Initialize the Customer
This will set the customer based on what has been previously stored in the session, otherwise it will retrieve the latest customer associated with the authenticated user.This is automatically called when the facade is resolved.
Set the Customer
Get the Customer
Returns the currently activeCustomer model, or null if no customer has been set.
Currencies
Initialize the Currency
This will set the currency based on what has been previously stored in the session, otherwise it will use the default currency.This is automatically called when the facade is resolved.
Set the Currency
setCurrency method accepts a Currency model instance. The currency code is stored in the session so it can be restored on subsequent requests.
Get the Currency
Returns the currently activeCurrency model.
Clearing the Session
To remove all storefront session data (channel, currency, customer, and customer groups), call theforget method.