-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch an error while importing huge CSV in queue using laravel excel #3
Comments
hi do you have find any soultion for this ? |
Hello @animeshs-reconnectin , Sad, you are also suffering from this. Actually, I uninstall this package and handle it manually. What I have done is I have created separate chunks of array let's say 1000 then 2 chunks of 500 records validate it using laravel standard method whatever validation errors I am getting I have dumped into validation error CSV. Now, I set this process into the laravel queue so it will process 500 records each and append the validation errors. Then after I checked into jobs table if there are any jobs left based on the name of the job if not then send a validation error CSV to the client that the process has been completed successfully. Hope this helps and let me know if you need further help. thanks! |
ok thank you @shashankdevstree |
sorry, but I can not share the code if you need an idea I can help you with that. |
@shashankdevstree its ok |
I am using ShouldQueue method to have the large CSV into Queue but the errors of validations I am not able to catch them!
public function registerEvents(): array { return [ ImportFailed::class => function(ImportFailed $event) { dd($event); // This I will write into the FILE or send EMAIL but the job runs successfully but validation errors keep empty. $this->importedBy->notify(new ImportHasFailedNotification); }, ]; }
My code looks like below...
public function registerEvents(): array { return [ ImportFailed::class => function(ImportFailed $event) { $filename = public_path('tmp').'/validation_error.txt'; $myfile = fopen($filename, "w"); fwrite($myfile, "domo"); fclose($myfile); }, ]; }
I am in hope that if there is any error validation_error.txt file will have "Demo" inside it.
I just wanted to add those errors in a file and email to the user that's it.
Also, I have crossed verify by removing ShouldQueue it gives me proper errors for email already exists a kind of.
Please help if you have any ideas! Thanks!
The text was updated successfully, but these errors were encountered: