Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
Hello Laravel Aimeos!
I am developing a "multishop" project. I have created two stores: shop1 and shop2.
The shop1 store is the default one, which should be displayed at https://mydomain.com, and shop2 should be displayed at https://shop2.mydomain.com.
I have followed the steps mentioned in the documentation and configured the routes as follows:
In the router/web.php file, I have added the following:
I have created two different themes for each store. In the shop.php configuration file, I have the following setting:
This causes the error: No item found for conditions: Array ( [locale.site.code] => default )
This error can be resolved by setting the code for one of the sites. However, when I do this, the home page always displays the template of the store with the configured code.
I noticed that in the themes, there is the mshop.php configuration file, and I added the following configurations:
packages/shop1/config/mshop.php
packages/shop2/config/mshop.php
However, this doesn't work, and it doesn't override the default configuration in config/shop.php.
While investigating, I noticed that in the file: vendor/aimeos/aimeos-laravel/src/Aimeos/Shop/Base/Locale.php, only the configuration from config/shop.php is being taken into account, and it doesn't consider the specific configurations of each theme: I would greatly appreciate your assistance.
Best regards!
I am developing a "multishop" project. I have created two stores: shop1 and shop2.
The shop1 store is the default one, which should be displayed at https://mydomain.com, and shop2 should be displayed at https://shop2.mydomain.com.
I have followed the steps mentioned in the documentation and configured the routes as follows:
Code: Select all
'routes' => [
'admin' => ['domain' => '{site}.mydomain.com', 'prefix' => 'admin', 'middleware' => ['web']],
'jqadm' => ['domain' => '{site}.mydomain.com', 'prefix' => 'admin/jqadm', 'middleware' => ['web', 'auth']],
'graphql' => ['domain' => '{site}.mydomain.com', 'prefix' => 'admin/graphql', 'middleware' => ['web', 'auth']],
'jsonadm' => ['domain' => '{site}.mydomain.com', 'prefix' => 'admin/jsonadm', 'middleware' => ['web', 'auth']],
'jsonapi' => ['domain' => '{site}.mydomain.com', 'prefix' => 'jsonapi', 'middleware' => ['web', 'api']],
'account' => ['domain' => '{site}.mydomain.com', 'prefix' => 'profile', 'middleware' => ['web', 'auth']],
'default' => ['domain' => '{site}.mydomain.com', 'prefix' => 'shop', 'middleware' => ['web']],
'update' => ['domain' => '{site}.mydomain.com'],
],
Code: Select all
Route::group(['domain' => '{site}.mydomain.com', 'middleware' => ['web']], function () {
Route::get('/', '\Aimeos\Shop\Controller\CatalogController@homeAction')
->name('aimeos_home')->where( ['site' => '[a-z0-9\-]+'] );
});
Code: Select all
'mshop' => [
'locale' => [
'site' => 'default', // used instead of "default"
]
],
This error can be resolved by setting the code for one of the sites. However, when I do this, the home page always displays the template of the store with the configured code.
I noticed that in the themes, there is the mshop.php configuration file, and I added the following configurations:
packages/shop1/config/mshop.php
Code: Select all
<?php
return [
'locale' => [
'site' => 'shop1',
]
];
Code: Select all
<?php
return [
'locale' => [
'site' => 'shop2',
]
];
While investigating, I noticed that in the file: vendor/aimeos/aimeos-laravel/src/Aimeos/Shop/Base/Locale.php, only the configuration from config/shop.php is being taken into account, and it doesn't consider the specific configurations of each theme: I would greatly appreciate your assistance.
Best regards!
Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
"mydomain.com" isn't a subdomain of itself, so your settings won't work. Use these instead:
Furthermore, set the default site to "mydomain.com":
And change the locale site codes in the admin backend to "mydomain.com" and "shop.mydomain.com" so both sites are matched by your route config.
Code: Select all
'routes' => [
'admin' => ['domain' => '{site}', 'prefix' => 'admin', 'middleware' => ['web']],
'jqadm' => ['domain' => '{site}', 'prefix' => 'admin/jqadm', 'middleware' => ['web', 'auth']],
'graphql' => ['domain' => '{site}', 'prefix' => 'admin/graphql', 'middleware' => ['web', 'auth']],
'jsonadm' => ['domain' => '{site}', 'prefix' => 'admin/jsonadm', 'middleware' => ['web', 'auth']],
'jsonapi' => ['domain' => '{site}', 'prefix' => 'jsonapi', 'middleware' => ['web', 'api']],
'account' => ['domain' => '{site}', 'prefix' => 'profile', 'middleware' => ['web', 'auth']],
'default' => ['domain' => '{site}', 'prefix' => 'shop', 'middleware' => ['web']],
'update' => ['domain' => '{site}'],
],
Code: Select all
'mshop' => [
'locale' => [
'site' => 'mydomain.com', // used instead of "default"
]
],
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
Thank you for the provided information. However, it seems that when I access https://shop2.mydomain.com, I still see the template of the theme configured for https://mydomain.com (shop1). The template/theme I have created and configured for shop2 doesn't appear.
Interestingly, on other pages such as shop, product detail, catalog list, etc., the appropriate theme is displayed.
Please let me know if there's any additional information or configuration I should consider to resolve this issue.
Thank you for your assistance!
Best regards!
Interestingly, on other pages such as shop, product detail, catalog list, etc., the appropriate theme is displayed.
Please let me know if there's any additional information or configuration I should consider to resolve this issue.
Thank you for your assistance!
Best regards!
Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
I have noticed that it only works if I access it in the following way: https://shop2.mydomain.com/?locale=es&s ... domain.com
Certainly, this is not a user-friendly URL.
What I want is for https://shop2.mydomain.com to correctly display the catalog-home component of the theme I have created for shop2.
I have followed the instructions in the documentation: https://aimeos.org/docs/2023.x/laravel/ ... /#homepage
However, it still doesn't work as expected.
Please provide any additional details or configuration steps that may help resolve this issue.
Thank you for your support!
Best regards!
Certainly, this is not a user-friendly URL.
What I want is for https://shop2.mydomain.com to correctly display the catalog-home component of the theme I have created for shop2.
I have followed the instructions in the documentation: https://aimeos.org/docs/2023.x/laravel/ ... /#homepage
However, it still doesn't work as expected.
Please provide any additional details or configuration steps that may help resolve this issue.
Thank you for your support!
Best regards!
Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
The route for the home page needs to be adapted too:
Code: Select all
Route::group(['domain' => '{site}', 'middleware' => ['web']], function () {
Route::get('/', '\Aimeos\Shop\Controller\CatalogController@homeAction')
->name('aimeos_home')->where( ['site' => '[a-z0-9\-]+'] );
});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
Hello,
That's exactly how I have it configured but it doesn't work either:
routes/web.php:
That's exactly how I have it configured but it doesn't work either:
routes/web.php:
Code: Select all
<?php
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
$params = [];
$conf = ['prefix' => '', 'where' => []];
if( env( 'SHOP_MULTILOCALE' ) )
{
$conf['prefix'] .= '{locale}';
$conf['where']['locale'] = '[a-z]{2}(\_[A-Z]{2})?';
$params = ['locale' => app()->getLocale()];
}
if( $conf['prefix'] )
{
Route::group(['domain' => '{site}', 'middleware' => ['web']], function () {
Route::get('/', '\Aimeos\Shop\Controller\CatalogController@homeAction')
->name('aimeos_home')->where( ['site' => '[a-z0-9\-]+'] );
});
}
Route::group($conf ?? [], function() {
require __DIR__.'/auth.php';
});
Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
If you don't have configured SHOP_MULTILOCALE=true, then you have to remove the "if( $conf['prefix'] )" condition.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
It is set to true. Since I have configured two languages (spanish and english)
Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
Add a redirect to the default language, e.g. "/en" before the if condition in the ./routes/web.php file so the home page route can match.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Multishop Configuration Issue: Overriding Locale Settings in Laravel Aimeos
It doesn't work either, I get a 404 error. I share with you my configurations:
config/shop.php
routes/web.php:
config/shop.php
Code: Select all
$prefix = config( 'app.shop_multilocale' ) ? '{locale}/' : '';
$config = [
'apc_enabled' => false, // enable for maximum performance if APCu is available
'apc_prefix' => 'aimeos:', // prefix for caching config and translation in APCu
'num_formatter' => 'Locale', // locale based number formatter (alternative: "Standard")
'pcntl_max' => 4, // maximum number of parallel command line processes when starting jobs
'version' => env( 'APP_VERSION', 1 ), // shop CSS/JS file version
'routes' => [
'admin' => ['domain' => '{site}', 'prefix' => $prefix . 'admin', 'middleware' => ['web']],
'jqadm' => ['domain' => '{site}', 'prefix' => 'admin/jqadm', 'middleware' => ['web', 'auth']],
'graphql' => ['domain' => '{site}', 'prefix' => 'admin/graphql', 'middleware' => ['web', 'auth']],
'jsonadm' => ['domain' => '{site}', 'prefix' => 'admin/jsonadm', 'middleware' => ['web', 'auth']],
'jsonapi' => ['domain' => '{site}', 'prefix' => 'jsonapi', 'middleware' => ['web', 'api']],
'account' => ['domain' => '{site}', 'prefix' => $prefix . '/profile', 'middleware' => ['web', 'auth']],
'default' => ['domain' => '{site}', $prefix . 'shop', 'middleware' => ['web']],
'supplier' => ['domain' => '{site}', 'prefix' => $prefix . 's', 'middleware' => ['web']],
'page' => ['domain' => '{site}', 'prefix' => $prefix . 'p', 'middleware' => ['web']],
'home' => ['domain' => '{site}', 'prefix' => $prefix, 'middleware' => ['web']],
'update' => ['domain' => '{site}'],
],
...
// other settings
...
'mshop' => [
'locale' => [
'site' => 'mydomain.com',
]
],
];
Code: Select all
<?php
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
$params = [];
$conf = ['prefix' => '', 'where' => []];
if( env( 'SHOP_MULTILOCALE' ) )
{
$conf['prefix'] .= '{locale}';
$conf['where']['locale'] = '[a-z]{2}(\_[A-Z]{2})?';
$params = ['locale' => app()->getLocale()];
}
if( env( 'SHOP_MULTISHOP' ) )
{
// $conf['prefix'] .= '/{site}';
$conf['where']['site'] = '[A-Za-z0-9\.\-]+';
}
if( $conf['prefix'] )
{
Route::group(['domain' => '{site}', 'middleware' => ['web']], function () {
Route::get('/', '\Aimeos\Shop\Controller\CatalogController@homeAction')
->name('aimeos_home')->where( ['site' => '[a-z0-9\-]+'] );
});
}
Route::group($conf ?? [], function() {
require __DIR__.'/auth.php';
});