Multistore Architecture
Relevant source files
The following files were used as context for generating this wiki page:
PrestaShop Multistore architecture allows a single installation to manage multiple shops. These shops can share data or remain independent depending on the configuration. The system utilizes a hierarchical structure consisting of Shop Groups and individual Shops to organize data and settings across different front-office domains or virtual URLs.
Sources: .ai/MULTISTORE.md, tests/UI/campaigns/modules/37_psgdpr/02_configuration/07_multistore.ts:133-176
Core Components and Hierarchy
The multistore system relies on three primary levels of scope: All Shops, Shop Group, and Shop. This hierarchy determines how configuration values are retrieved and persisted.
Multistore Hierarchy
The following diagram illustrates the relationship between the different entities in the multistore system.
The system defines clear boundaries for data access and configuration overrides based on these levels.
Sources: .ai/MULTISTORE.md, src/Core/Domain/Shop/ValueObject/ShopConstraint.php:30-45
Multistore Configuration Management
Configuration settings in a multistore environment are handled by specialized classes that manage values across different shop contexts. The MultistoreConfig class provides methods to retrieve and update settings based on the active shop or group.
Configuration Methods
| Method | Description |
|---|---|
get() | Retrieves a configuration value for a specific shop or shop group. |
update() | Updates a configuration value for a specific shop or shop group. |
Sources: src/Core/Multistore/MultistoreConfig.php:40-60
Shop Constraints
The ShopConstraint value object encapsulates the limitations and context of a shop operation. It identifies whether an action applies to a specific shopId, a shopGroupId, or the entire installation.
// Example of ShopConstraint structure
public function __construct(
?int $shopId = null,
?int $shopGroupId = null
) {
$this->shopId = $shopId;
$this->shopGroupId = $shopGroupId;
}
Sources: src/Core/Domain/Shop/ValueObject/ShopConstraint.php:47-65
Multistore Operational Flow
Enabling and configuring multistore involves several steps in the Back Office, from activating the feature to creating shop URLs.
Feature Activation and Shop Creation
- Enable Multistore: You activate the feature in Shop Parameters > General.
- Create Shop Group: You define a group (e.g., "Default") to house related shops.
- Create Shop: You add a new shop entity and assign it to a group and root category.
- Set Virtual URL: You assign a domain or virtual URI to the shop to make it accessible in the Front Office.
Sources: tests/UI/campaigns/modules/37_psgdpr/02_configuration/07_multistore.ts:114-165
Shop Selection Sequence
When a merchant interacts with the Back Office in a multistore environment, the system must resolve the current shop context to display the correct data.
Module Compatibility
Modules must explicitly support multistore to function correctly across different contexts. For example, the GDPR module (psgdpr) allows customizing consent checkboxes per shop. When the Back Office context is set to a specific shop, the module configuration page loads the settings specific to that shop ID.
Sources: tests/UI/campaigns/modules/37_psgdpr/02_configuration/07_multistore.ts:80-100, tests/UI/campaigns/modules/37_psgdpr/02_configuration/07_multistore.ts:194-205
Conclusion
The Multistore Architecture provides a scalable way to run multiple e-commerce sites from a single PrestaShop instance. By leveraging a hierarchical context system (All Shops, Groups, and Shops) and strict configuration management via MultistoreConfig and ShopConstraint, the platform ensures that data is isolated or shared according to the merchant's business requirements.