Symfony/Configure multiple shops

From Aimeos documentation

This page contains changes which are not marked for translation.

Other languages:
English 100%

2016.x version

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

Create new site

Since version 1.1 of the Aimeos bundle, creating a new site is very easy. You only need to execute this command in the base directory of your Symfony application:

php bin/console aimeos:setup <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). If no value for "<template site>" is given, "default" is used.

If you update Aimeos from a previous version, you need to run the "aimeos:setup" command 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 Symfony 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 bundle contains a routing definition that can be extended for several shops. Simply use the "{site}" placeholder to your prefix setting and add the routes for the administration interface:

  1. aimeos_shop:
  2.     resource: "@AimeosShopBundle/Resources/config/routing.yml"
  3.     prefix:   /{site}/
  4.     defaults: { site: 'default' }
  6. aimeos_shop_admin:
  7.     path: /admin
  8.     defaults: { _controller: AimeosShopBundle:Admin:index }
  10. aimeos_shop_admin_check:
  11.     path: /admin_check

The difference is the value for the "prefix" parameter ("/{site}/" instead of just "/"). Then, the path of all routes additionally start with /{site}/ which contains the shop site code. The routes for the administration interface are necessary to leave them not prefixed. More details about the "prefix" setting including the possibility to add language and currency placeholders can be found in the article about custom routes.

It's good to set a default value for the site parameter if you have multiple sites! This prevents wrong links if no site value is available at the current page.