Create extension

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)
Spam and unrelated posts will be removed immediately!
User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Create extension

Post by nvdid » 14 Feb 2024, 21:04

Hi
I'm a newbie. I registered and submitted a topic in here today. But now I couldn't login and my email didn't seem to work for login either. I registered using github with the same email now. Plus I don't see the topic I posted. Can somebody help me out here please?

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

Re: Create extension

Post by aimeos » 15 Feb 2024, 08:05

For new users, the first two posts need to be manually approved.
Please post your question again.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Create extension

Post by nvdid » 15 Feb 2024, 11:23

Right. But yet I don't get why I couldn't login to account then after..

Ok back to the question. I appreciate if anyone could help me get familiar with the process of customizing aimeos and creating an extension.
I used extension builder to have an empty extension project.

How can I add routes to the jsonapi and handle them in my extension?
Can I handle current jsonapi routes in my extension? For example if specific query parameters existed.

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

Re: Create extension

Post by aimeos » 16 Feb 2024, 17:20

nvdid wrote: 15 Feb 2024, 11:23 Right. But yet I don't get why I couldn't login to account then after..
Sorry, maybe your account got accidentally deleted if your post looked like spam (very short with no details).
nvdid wrote: 15 Feb 2024, 11:23 How can I add routes to the jsonapi and handle them in my extension?
Can I handle current jsonapi routes in my extension? For example if specific query parameters existed.
The JsonApi controller already handles all JSON:API methods (GET, POST, PATCH, DELETE, OPTIONS) and maps them to the available Aimeos resources (=data domains/managers). Therefore, you don't need any additional routes. Only if you want to add routes for non-Aimeos related things but then you have to check how you can do that in the host framework (Laravel, etc.)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Create extension

Post by nvdid » 16 Feb 2024, 21:56

Right. Thanks so much for the support.

Im trying to find out how I can extend aimeos and what are the limitations. Let's say I want to add a new key (calculated based on known params at runtime) to the response of some route (ai domain) of jsonapi. Can I do it in the extension and without touching the aimeos core?

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

Re: Create extension

Post by aimeos » 17 Feb 2024, 13:20

You can implement everything without touching the Aimeos core files because you can overwrite every class with your own implementation.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Create extension

Post by nvdid » 18 Feb 2024, 13:25

Thanks for the hint. I had some progress in getting familiar with the project.

I'm trying to make some customization; so the user is able to see the created date in cms, for example by fetching jsonapi/cms.

My current solution is to change the following in my extension and add date property:
https://github.com/aimeos/ai-cms-grapes ... d.php#L166

I had to copy the Item/Standard.php file to my extension and then tell the composer to use my file for the namespace over the original, which I doubt is the correct approach.

I know we can set classes to be used in configs and replace the Standard with our class. But apparently this is not the case as there is no config for it. I read the documents about submanagers and decorators. Are they the way to do it? Or config?

I appreciate if you guide me through this. Would be a great progression for me

Edit: Now we can have the date in 2023.10.x-dev. But still would be great if I could learn how we can extend similar features in an extension :)

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

Re: Create extension

Post by aimeos » 19 Feb 2024, 08:04

nvdid wrote: 18 Feb 2024, 13:25 I know we can set classes to be used in configs and replace the Standard with our class. But apparently this is not the case as there is no config for it. I read the documents about submanagers and decorators. Are they the way to do it? Or config?
If you want to overwrite a sub-manager class, it works the same way as for the domain managers and you must set the new class name in the config, e.g. if you want to overwrite the product OR product property manager with your own implementation:

Code: Select all

    'product' => [
        'manager' => [
            // use this if you want to overwrite the product manager
            'name' => 'Myproduct',
            'property' => [
                // OR this to overwrite the product property manager
                'name' => 'Myproperty',
            ]
        ]
    ]
See: https://aimeos.org/docs/latest/models/e ... figuration
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
nvdid
Posts: 15
Joined: 14 Feb 2024, 20:56

Re: Create extension

Post by nvdid » 19 Feb 2024, 10:47

Right. If I understood correctly, this way we can overwrite manager for cms or e.g. cms/media.

But I don't get it for Cms/Item/Standard.php (https://github.com/aimeos/ai-cms-grapes ... andard.php). Are you suggesting to set config mshop/cms/manager/lists/type/name for that? Because I see direct usages of Cms/Item/Standard.php in the Cms/Manager/Standard.php file which is outside the lists.

Or do you mean I should overwrite mshop/cms/manager and also use my own implementations for Item\Standard instead of e.g. https://github.com/aimeos/ai-cms-grapes ... d.php#L791.

What I'm trying to understand is whether the Cms/Item/Standard.php is configurable and where there might be direct usages of its class in the aimeos (like the link above).

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

Re: Create extension

Post by aimeos » 21 Feb 2024, 10:54

nvdid wrote: 19 Feb 2024, 10:47 What I'm trying to understand is whether the Cms/Item/Standard.php is configurable and where there might be direct usages of its class in the aimeos (like the link above).
No, items are not configurable but bound to the manager which creates them. To use another item implementation, you have to overwrite the createItemBase() method in your own manager.

Alternatively, you can add macros to items if you want to implement own logic:
https://aimeos.org/docs/latest/models/e ... properties
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply