Run Aimeos jobs in Laravel controller

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!
D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Run Aimeos jobs in Laravel controller

Post by D-Cell » 21 Dec 2019, 21:09

Hello! I`m writing custom product import script for my project.

It helps the shop admin to choose which columns from Excel file have to be imported.
After admin finishes, the script saves the final CSV file to my local storage (public/csv/products directory).
After that i have to run

Code: Select all

php artisan aimeos:jobs product/import/csv myshop
in console to import products.

What i try to achieve is running

Code: Select all

php artisan aimeos:jobs product/import/csv myshop
in my controller, not in console.

Laravel allows me to run console commands in controllers using Artisan::call() function, so i tried next:

Code: Select all

Artisan::call('aimeos:jobs', ['jobs' => 'product/import/csv', 'site' => 'smartshop']);
and

Code: Select all

Artisan::call('aimeos:jobs product/import/csv smartshop');
Unfortunately, none of those options didn't give any result.

Is there any way to run Aimeos jobs within Laravel controller?

System: Aimeos 2019.07, Laravel 5.8, Fedora 30, PHP 7.3

Thank you for your time and have a happy upcoming holidays!

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

Re: Run Aimeos jobs in Laravel controller

Post by aimeos » 24 Dec 2019, 13:07

If nothing works, you can also implement the code from the aimeos:jobs command directly:
https://github.com/aimeos/aimeos-larave ... nd.php#L47
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

tulparstudyo

Re: Run Aimeos jobs in Laravel controller

Post by tulparstudyo » 27 Feb 2021, 10:09

Hello, I have created a job controller to importing products from xlsx file.
The controller working correctly on console command
php artisan aimeos:jobs "product/import/xlsx" "default"
php artisan aimeos:jobs "product/export/xlsx" "default"


I want to implement this job controler like aimeos: $Xlsx = new \Aimeos\Shop\Command\JobsCommand();
How can I do the implementing and configure this JobsCommand;

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

Re: Run Aimeos jobs in Laravel controller

Post by aimeos » 01 Mar 2021, 10:51

Don't know if this is really useful but if you want to have an own, specific command, you can use the aimeos:jobs command as reference:
https://github.com/aimeos/aimeos-larave ... ommand.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
tulparstudyo
Posts: 3
Joined: 03 Mar 2021, 08:39

Re: Run Aimeos jobs in Laravel controller

Post by tulparstudyo » 03 Mar 2021, 08:45

Thanks,
I solved the problem. Now I can product import and product export on the admin panel by xlsx file upload.
https://github.com/tulparstudyo/sw-xlsx

veeran ambalam
Posts: 19
Joined: 06 Mar 2021, 14:51

Re: Run Aimeos jobs in Laravel controller

Post by veeran ambalam » 23 Apr 2021, 16:44

@tulparstudyo Can you please explain this "https://github.com/tulparstudyo/sw-xlsx"

Post Reply