I write my own a function to import products from CSV file, that file was exported from another site
So the process is:
1/ User upload that file to my server
2/ Read that file and make a loop through all rows
3/ get the image link in "image" field --> download it to my server
4/ check if SKU has been use or not to Insert or Update
If it loops through 5000 products --> long long time and maybe database error as in attached file


I think about close DB connect for each 500 products then open DB connect again but not sure how to do it in Opencart
Any solution to make it works effective, anyone have idea please?
Thank you