Answer the question
In order to leave comments, you need to log in
How to properly save a row in a CSV file to import a WooCommerce product?
I have a parser, everything works well, except for the record, it somehow writes crookedly. Here is my code:
Here I process the date, turning it into a string to write ( 1 string == 1 product ):
// сделал переменную всей строки.
$parsed_string = $parse_cat . ',' . $parse_sub_cat . ';' . $product_title . ';' . $product_desc . ';';
// убрал переносы
$sanitize_strings = array("\r", "\n", " ");
$encode_strings = str_replace($sanitize_strings, "", $parsed_string);
//убрал хтмл теги и привел к необходимой кодировке.
$win_encode_string = array(htmlspecialchars_decode (iconv( "UTF-8" , "WINDOWS-1251", $encode_strings)));
//открыл файл
$fileopen = fopen('parsed_data.csv', 'a');
//положил нашу строку, все данные которые вытянули и обработал
fputcsv($fileopen, $win_encode_string);
//закрыл файл.
fclose($fileopen);
Категория;"Метки товара";"Артикул";"Наименование";"Подробное описание";"Краткое описание";"Цена";"Цена со скидкой";"Кол-во на складе";"Цвет";"Перекрестные товары";"Картинка";"ATTACHMENT";"ATTACHMENT";"Статус товара";virtual;downloadable;file_paths
Категория_1, категория_2;название товара;описание товара;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question