Import CSV file located in an external URL in WooCommerce

237 views Asked by At

So, my main issue is this. Right now i have a page running with AWS's Elastic Beanstalk with more than 1 instance running. The main issue is that the CSV importer uploads the file to the instance, but for the next step, WC checks again if the file exist, and because it can change instance while this is running, the file might not exist. So the idea i came up is uploading the file on S3 and check if there's any way to get, read and process the import with a link like this: https://app-s3.s3.amazonaws.com/folder/TestFile.csv I managed to read the contents of the file from PHP, but the main issue is that the built in importer class doesn't process string or arrays, it actually reads multiple times the CSV file, so this option it's kinda useless.

I also tried to use the class WC_Product_CSV_Importer, which has been kinda successful, but the mapping it's totally broken or i don't get how to set it up correctly, since woocommerce documentation on this class it's really useless and don't explain anything.

Right now i'm at 0 with this issue and i ran out of ideas or options... I could try external plugins if there's one that can do the job, but the main goal it's to build it inside the theme.

1

There are 1 answers

0
Daryl On

So, i ended up using EFS, making a shared folder between both instances and a little function to download a csv to that specific folder, then grab the local URL of the file and paste it no the integrated WP importer