How to add own action to admin ?

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!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

How to add own action to admin ?

Post by MikaelNazarenko » 16 Jul 2019, 17:10

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

As I see \Aimeos\Shop\Controller\JqadmController has several actions like 'get', 'search' and other. I need implement my own action 'download'. And this action must send file to browser. In my \Aimeos\Admin\JQAdm\Documents\Standard class I try to do it under export action:

Code: Select all

return response()->download($file); 
But it doesn't work, file is not downloaded. Browser just show me html code. I think it is because each action of \Aimeos\Shop\Controller\JqadmController does the following:

Code: Select all

return $this->getHtml( $html );
How can I avoid it ?

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

Re: How to add own action to admin ?

Post by aimeos » 17 Jul 2019, 08:54

You should create your own action that handles the output for downloads correctly, Then, you can configure the named route you've defined for your action in the Aimeos config: https://github.com/aimeos/aimeos-larave ... lt.php#L70

In your JQAdm class, you need to use

Code: Select all

$this->config( 'admin/jqadm/url/download/target' )
to retrieve the named route and pass it to the "$this->url()" method to generate the required URL.

We would love to get your changes into Aimeos. Can you create a pull request on GitHub for your changes?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply