Based on the idea above, I would like to suggest the new import functions which will handle JSON files (vehicle information and Images).
- Define API, log request, log response
- Define security API (basic authentication, spam,...)
- Mapping JSON data to WebEd object for import vehicles
- Handler import functions (need to create the new function for import)
- Handler downloads images and Mapping with vehicle (download and convert to WebP)
We separate the import function, but we still keep the same goal "Vehicle Import Correctly and Vehicle's Image correctly"
Summary of the Original Import Workflow:
- Write log import
- Get vehicle site setting
- Move file upload to process
- Get dealer name
- Get dealer state
- Import vehicle from file to VehicleLogs tables
- Loop all file
- Read line by line
- Check stocknumber exist
- Update/insert VehicleLogs
- Check and update vehicle images
- Output total records, start index - end index
- Move vehicles from VehicleLogs to Vehicles
- Clean up the VehicleLogs
- Convert WebP for all uploaded images