Slim/Configure multiple shops

From Aimeos documentation

Slim
Other languages:
English 100%

Aimeos is multi-site capable and allows storing several shops in one database.

Create new site

Creating a new site is very easy. You only need to execute this command in the base directory of your Slim application:

php <appdir>/vendor/aimeos/aimeos-core/setup.php --config=<appdir>/src/aimeos-settings.php --extdir=<appdir>/ext/ [--option="..."] <site code> [<template site>]

The value for "<site code>" can be either a new site code for creating a new site or an existing site code for updating a site. The "<template site>" code is optional and tells the setup command which site to use as reference when creating a new site (currently "default", "unittest" and "unitperf" are available as templates). For new production sites, "default" should always be used.

If you update Aimeos from a previous version, you need to run the "setup.php" scripts for all sites you've created! Otherwise, required records may be missing and existing data isn't migrated.

Don't forget to create the appropriate "locale" entries for your new site in the administration interface!

Adapt the routing

In order to tell your Slim application which shop should be used, you have to use routes that include at least the "site" parameter. This is not necessary for the first shop (site: default).

The Aimeos shop package contains routes packaged into some route groups ("login", "admin", "account", "default", "confirm" and "update") that can be configured to support more than one shop. You have to add a "prefix" parameter with the value "{site}" in your ./src/aimeos-settings.php:

  1. 'routes' => array(
  2. 	'account' => array('prefix' => '/{site}'),
  3. 	'default' => array('prefix' => '/{site}'),
  4. 	'confirm' => array('prefix' => '/{site}'),
  5. ),

Then, the path of all routes additionally start with /{site}/ which contains the shop site code. There's no strict need to prefix the routes for "login", "admin" and "update", but you can give them a prefix as well. More details about the "prefix" setting including the possibility to add language and currency placeholders can be found in the article about custom routes.