How to configure and adapt Aimeos based shops as developer
Forum rules: Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#6172 by imaresca91
31 May 2018, 15:31

I recently builded a new extension (myproject/ext) and configured it for creating a new table called departaments with the corresponding Item and Manager (I am not sure is I did the things right). But now I need to create a CRUD for that table so I can manipulate the data from another server.
I was wondering if someone can help me with this issue.
Sorry for my poor english, I wish you can understand.

Thanks for the help!.
#6179 by imaresca91
01 Jun 2018, 09:44
Thank you very much for quick reply!.

I created:
1 - JsonAdmin Standard class (ext\departaments\admin\jsonadm\src\admin\JsonAdmin\Standard.php).
2 - Departament Standard class (ext\departaments\admin\jsonadm\src\admin\JsonAdmin\Departament\Standard.php).
3 - Template get-standard.php (ext\departaments\admin\jsonadm\templates\get-standard.php)

Doubts and comments:
1, 3 - The code of this classes are the same like the github that was specified in the last reply.
2 - I attach the code of the getListItems function, namespace and extends/implement class because I am not sure if it is ok.
In the getListItems, where I have to implement the departaments/list...?
Code: Select allprotected function getListItems( array $items, array $include )
        $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'departament/lists' );
        $search = $manager->createSearch();
        $expr = array(
            $search->compare( '==', 'departament.lists.parentid', array_keys( $items ) ),
            $search->compare( '==', 'departament.lists.domain', $include ),
        $search->setConditions( $search->combine( '&&', $expr ) );
        return $manager->searchItems( $search );

Code: Select allnamespace ext\departaments\admin\jsonadm\src\admin\JsonAdmin\Departament;

Code: Select allclass Standard extends \Aimeos\Admin\JsonAdm\Standard implements \Aimeos\Admin\JsonAdm\Common\Iface

Then i tried Admin/JSONAPI tutorial ( ... e_metadata) but I could not access to my departaments data. Perhaps I have to register my new endpoint in the resources options.

Please, let me know if something is not clear so I can explain it again. I am new at aimeos core.

Thank you very much for the help!. And congratulations about the library!.
#6185 by aimeos
01 Jun 2018, 21:00
You don't need to copy the Standard.php class. If you have no list or property table related to your department table, I think you don't have to create a class at all because it's then handled by the Standard.php class. As you mentioned correctly, you need to configure your "department" class so it will be added to the meta information:
#6210 by imaresca91
05 Jun 2018, 16:02

Thank you very much for you reply!.

I just configured my extension correctly. But the problem now is that I have to pass a Laravel cookie to tell Laravel I am athenticated and let me work with my department's CRUD. Also, I tried using passport:client token but it does not work. So the question is, how can I deal with aimeos jsonadm/department requests (GET, POST, PATCH, etc..) without passing a Laravel cookie.

Thanks for your help!.
#6212 by aimeos
06 Jun 2018, 07:21
You can't because you have to authenticate first. Otherwise, everyone could add, modify or delete records from your shop and believe me, you don't want that!
#6213 by imaresca91
06 Jun 2018, 08:20
But I don't want to use it without athentication. That's why I want to use passport and an access token.
Aimeos works fine with Laravel passport?, because I didn't have success on it.