Access Managers in Laravel Controller

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!
kartikbhat
Posts: 40
Joined: 02 Dec 2021, 17:18

Access Managers in Laravel Controller

Post by kartikbhat » 06 Apr 2022, 18:03

I need to access those Managers which handles 'products' into my Custom Laravel Controller ; How can I fetch list of products from database ;

Code: Select all

$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
this chunk is not working inside of laravel controller;

Help me access products list within my Laravel Controller

TIA :)

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

Re: Access Managers in Laravel Controller

Post by aimeos » 08 Apr 2022, 06:40

Use this code to get the context in Laravel:

Code: Select all

$context = app( 'aimeos.context' )->get();
Please read the documentation too:
https://aimeos.org/docs/latest/laravel/ ... os-objects
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kartikbhat
Posts: 40
Joined: 02 Dec 2021, 17:18

Re: Access Managers in Laravel Controller

Post by kartikbhat » 08 Apr 2022, 08:00

How Can I fetch active siteid from session in Laravel Controller to utilize it to fetch other related data from database;
TIA

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

Re: Access Managers in Laravel Controller

Post by aimeos » 11 Apr 2022, 10:09

If you use the Aimeos frontend controllers or managers, the current site ID is automatically used.
Otherwise, you can get the site ID that way:

Code: Select all

$context->locale()->getSiteId()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply