Locale object not available after change routes

Help for integrating the Laravel package
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!
krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Locale object not available after change routes

Post by krzysiekp » 05 May 2022, 17:12

I have error "Locale object not available " when I change my routes in config/shop.php.

New entry is:

'routes' => [
'admin' => ['domain' => '{site}', 'prefix' => 'admin', 'middleware' => ['web']],
'jqadm' => ['domain' => '{site}', 'prefix' => 'admin/jqadm', '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}'],
]


Error occured in:

\vendor\aimeos\aimeos-core\lib\mshoplib\src\MShop\Context\Item\Standard.php:425

krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Re: Locale object not available after change routes

Post by krzysiekp » 05 May 2022, 22:17

I create custom page and try using Aimeos context object in my custom controller and I receive this error. And I change my site code from "default" to "test.localhost" Bellow line causes error:

app('aimeos.context')->get()

User avatar
aimeos
Administrator
Posts: 7926
Joined: 01 Jan 1970, 00:00

Re: Locale object not available after change routes

Post by aimeos » 06 May 2022, 05:10

The site code ("default" by default) must be changed to the domain in the URL (e.g. "test.localhost"). Furthermore, you have to adapt this setting in your ./config/shop.php to that domain too:
https://github.com/aimeos/aimeos-larave ... p.php#L123
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

krzysiekp
Posts: 85
Joined: 05 Nov 2021, 16:19

Re: Locale object not available after change routes

Post by krzysiekp » 06 May 2022, 06:10

But I have two sites. First site has site code = test.localhost and second site has site code = test2.localhost.
Each domain has this error.

User avatar
aimeos
Administrator
Posts: 7926
Joined: 01 Jan 1970, 00:00

Re: Locale object not available after change routes

Post by aimeos » 06 May 2022, 06:13

When using your custom controller, you also have a custom route, don't you?
In that case, make sure that the domain is also used as "{site}" parameter there.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply