'decode csv file to import in woocommerce using php
I am looking to import csv file into products wordpress but the file i have isn't helping me to do that. Whenever I import the file , random fields are assigned to the name and creates me tons of products with random names from the file.These are just some parts of the .csv file:
ID,ProductName,SKU,Description,Stok,Brand
30441,Chair auto with low seat,968B-23H Coffee,"<br><h1> Isofix Coffee
Crocodile 0 36 kg sleeping position 135 grade</h1>
<br><br><table><tbody><tr>
<td>
<img src="https://www.asdasd.jpg"></td>
<br><li>Fie pentru a <b>ancora suplimentar</b> inaltatorul de sistemul de prindere Isofix al masinii</li>
I have tried the following but doesn't allow me to import it and surely the format isn't going to allocate the product fields correctly.
$url = "Book1.csv";
$current = file_get_contents($url);
$a = htmlentities($current,ENT_QUOTES | ENT_SUBSTITUTE);
$d = htmlspecialchars_decode($a, ENT_QUOTES | ENT_SUBSTITUTE);
$f = html_entity_decode($d, ENT_QUOTES | ENT_SUBSTITUTE);
$patterns = array();
$patterns[1] = '/jpg;http/';
$replacements = array();
$replacements[0] = 'jpg,http';
$g = preg_replace($patterns, $replacements, $f);
file_put_contents('../php training/file.csv', $g);
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
