How can i override controller and his method by my extantion

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!
kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

How can i override controller and his method by my extantion

Post by kishanbupadhyaya » 24 Jun 2019, 13:57

Hi aimeos,

Basically i am creating my own extantion. i have followed following this link.
https://aimeos.org/docs/Developers/Create_an_extension

And i got result for only views but i want to override your controllers, method, Classes e.t.c but i am not getting result. it execute all logic from ai-client-html but i want to execute from my extention.

Please kindly help me and Thank you in advance.

Best Regaurds,
Kishan Upadhyay

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

Re: How can i override controller and his method by my extan

Post by aimeos » 24 Jun 2019, 17:33

Create a class with another name (namespace is the same as the existing class you want to overwrite), extend from the existing class and overwrite the methods you need. Then, configure the name of your new class e.g. for the catalog lists component: https://aimeos.org/docs/Configuration/C ... lists/name

You can also dynamically extend classes with decorators to add additional data for example:
https://aimeos.org/docs/Developers/Html ... components
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: How can i override controller and his method by my extan

Post by kishanbupadhyaya » 25 Jun 2019, 06:01

Thank you for replay aimeos and i have try as per your instruction and it worked.

One last thing that how you get data from database. i want to learn that how can i get data from database and make my own thing as per requirement. and thank you in advance.

Best Regards,
Kishan Upadhyay

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

Re: How can i override controller and his method by my extan

Post by aimeos » 25 Jun 2019, 15:54

Use the Aimeos frontend controllers to get the data you need:
https://github.com/aimeos/ai-controller ... r/Frontend
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: How can i override controller and his method by my extan

Post by kishanbupadhyaya » 26 Jun 2019, 05:13

Thank you aimeos for your support. Is there any config settings remains for this i apply frontend controllers in my extension but yet he executes from ai-controller-frontend.

Best Regards,
Kishan Upadhyay

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

Re: How can i override controller and his method by my extan

Post by aimeos » 26 Jun 2019, 10:35

Like all other classes you want to overwrite in Aimeos, you have to give yours a new name and configure that name e.g. for the product controller:
https://aimeos.org/docs/Configuration/C ... oduct/name
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kishanbupadhyaya
Posts: 16
Joined: 20 Jun 2019, 10:16

Re: How can i override controller and his method by my extan

Post by kishanbupadhyaya » 26 Jun 2019, 11:59

Hi Aimeos after following your step from documentation i getting this error. If you help me on this.

Best Regards,
Kishan Upadhyay
Attachments
Final Error i get is this.
Final Error i get is this.
Screenshot_3.jpg (198.31 KiB) Viewed 5968 times
see this class that i have made and name of file are alos same
see this class that i have made and name of file are alos same
Screenshot_2.jpg (188.45 KiB) Viewed 5968 times
Shop.php file
Shop.php file
Screenshot_1.jpg (65.08 KiB) Viewed 5968 times

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

Re: How can i override controller and his method by my extan

Post by aimeos » 27 Jun 2019, 09:07

Please make sure you are using the right interface for your installed version. Currently, you've installed Aimeos 2018.10 which uses this interface: https://github.com/aimeos/ai-controller ... ce.php#L78

But your class implements the newer 2019.04 interface: https://github.com/aimeos/ai-controller ... /Iface.php

The frontend controller interfaces have been rewritten in 2019.x to be much more intuitive and easier to use. If you want to implement your own frontend controllers, you should use Aimeos 2019.04+
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

alababdiy
Posts: 40
Joined: 30 Apr 2023, 12:46

Re: How can i override controller and his method by my extantion

Post by alababdiy » 02 Nov 2023, 10:58

@aimoes
all links is outdated , Please how i can overwrite aimeos-laravel/src/Controller/CheckoutController.php in my Extension?

Post Reply