I am creating a WordPress custom plugin to import product data in Woocommerce by uploading a CSV file. The CSV file contains different kinds of products (simple, variable, grouped, external) with custom attributes and a lot of data. You can look into the
MY GOAL : I want to upload a CSV file containing data of mixed product types like 100 simple products, 50 variable products, 20 external products, and 10 grouped products and then upload all products in Woocommerce.
CodePudding user response:
ParseCSV for PHP worked for me. If someone gets into the same situation, they can use this PHP class: https://github.com/parsecsv/parsecsv-for-php It returns CSV file data properly.
After opening the CSV file in PHP and getting file name, I add this PHP from code:
<?PHP
$csv = new \ParseCsv\Csv();
$csv->auto($csvFileName);
$csv_file_data = $csv->data;
?>
Then, I only needed to iterate the $csv_file_data
variable using foreach loop.
Specially thanks for @Deigo referring to that PHP class.