How to implement new entity into Aimeos admin panel ?
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!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
How to implement new entity into Aimeos admin panel ?
Hi, everybody, thank you for help.
My environment is the following:
Laravel Framework 5.8.26
aimeos-laravel 2019.04
PHP Version 7.2.19-1+ubuntu18.04.1+deb.sury.org+1
I build a project with Laravel+Aimeos and here I need to make a lot of customizations with aimeos admin panel.
I have implemented file attachments for users. For this I have created new table 'media'. I already have added new tab to admin panel. In this tab I need to display all attachments of current logged in user. Attachments can be retrieved by getMedia() method.
Aimeos structure is still not clear for me. I mean to display data I need get some manager object and do some staff like this:
So how can I display all attachments of current logged in user ?
In the documentation I have found that there are some domains are part of the Aimeos core, I think firstly I need add my new domain to the aimeos core ?
My environment is the following:
Laravel Framework 5.8.26
aimeos-laravel 2019.04
PHP Version 7.2.19-1+ubuntu18.04.1+deb.sury.org+1
I build a project with Laravel+Aimeos and here I need to make a lot of customizations with aimeos admin panel.
I have implemented file attachments for users. For this I have created new table 'media'. I already have added new tab to admin panel. In this tab I need to display all attachments of current logged in user. Attachments can be retrieved by getMedia() method.
Aimeos structure is still not clear for me. I mean to display data I need get some manager object and do some staff like this:
Code: Select all
$params = $this->storeSearchParams( $view->param(), 'media' );
$manager = \Aimeos\MShop::create( $context, 'media' );
/** @var \Aimeos\MW\Criteria\SQL $search */
$search = $this->initCriteria( $manager->createSearch(), $params );
$view->items = $manager->searchItems( $search, ['media'], $total );
In the documentation I have found that there are some domains are part of the Aimeos core, I think firstly I need add my new domain to the aimeos core ?
Re: How to implement new entity into Aimeos admin panel ?
The easiest way is to copy the product media subpanel (class + template) and rename every occurence of "Product" to "Customer" and "product" to "customer". Then, add "media" to the list of subparts in the customer panel configuration:
https://github.com/aimeos/ai-admin-jqad ... dm.php#L61
That should be all you need to get the media tab into the customer panel. The customer panel lists all customers if you haven't restricted it to the current logged in user ( $context->getUserId() should to the trick). For the customer, in the detail view only his media files will be listed in the new tab.
The manager code you mention can be used to retrieve media items from the database manually like this:
The initCriteria() method only sets the conditions and the sorting automatically depending on the given parameters.
https://github.com/aimeos/ai-admin-jqad ... dm.php#L61
That should be all you need to get the media tab into the customer panel. The customer panel lists all customers if you haven't restricted it to the current logged in user ( $context->getUserId() should to the trick). For the customer, in the detail view only his media files will be listed in the new tab.
The manager code you mention can be used to retrieve media items from the database manually like this:
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'media' );
$search = manager->createSearch();
$total = 0;
$view->items = $manager->searchItems( $search, [], $total );
$view->total = $total;
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star