fclose($fp);
function addPrestashopCSVHeader() {
$csvrow = array();
$csvrow[] = "Product ID";
$csvrow[] = "Active (0/1)";
$csvrow[] = "Name *";
$csvrow[] = "Categories (x,y,z...)";
$csvrow[] = "Price tax included";
$csvrow[] = "Tax rules ID";
$csvrow[] = "Wholesale price";
$csvrow[] = "On sale (0/1)";
$csvrow[] = "Discount amount";
$csvrow[] = "Discount percent";
$csvrow[] = "Discount from (yyyy-mm-dd)";
$csvrow[] = "Discount to (yyyy-mm-dd)";
$csvrow[] = "Reference #";
$csvrow[] = "Supplier reference #";
$csvrow[] = "Supplier";
$csvrow[] = "Manufacturer";
$csvrow[] = "EAN13";
$csvrow[] = "UPC";
$csvrow[] = "Ecotax";
$csvrow[] = "Width";
$csvrow[] = "Height";
$csvrow[] = "Depth";
$csvrow[] = "Weight";
$csvrow[] = "Quantity";
$csvrow[] = "Minimal quantity";
$csvrow[] = "Visibility";
$csvrow[] = "Additional shipping cost";
$csvrow[] = "Unity";
$csvrow[] = "Unit price";
$csvrow[] = "Short description";
$csvrow[] = "Description";
$csvrow[] = "Tags (x,y,z...)";
$csvrow[] = "Meta title";
$csvrow[] = "Meta keywords";
$csvrow[] = "Meta description";
$csvrow[] = "URL rewritten";
$csvrow[] = "Text when in stock";
$csvrow[] = "Text when backorder allowed";
$csvrow[] = "Available for order (0 = No, 1 = Yes)";
$csvrow[] = "Product available date";
$csvrow[] = "Product creation date";
$csvrow[] = "Show price (0 = No, 1 = Yes)";
$csvrow[] = "Image URLs (x,y,z...)";
$csvrow[] = "Image alt texts (x,y,z...)";
$csvrow[] = "Delete existing images (0 = No, 1 = Yes)";
$csvrow[] = "Feature(Name:Value:Position)";
$csvrow[] = "Available online only (0 = No, 1 = Yes)";
$csvrow[] = "Condition";
$csvrow[] = "Customizable (0 = No, 1 = Yes)";
$csvrow[] = "Uploadable files (0 = No, 1 = Yes)";
$csvrow[] = "Text fields (0 = No, 1 = Yes)";
$csvrow[] = "Out of stock";
$csvrow[] = "ID / Name of shop";
$csvrow[] = "Advanced stock management";
$csvrow[] = "Depends On Stock";
$csvrow[] = "Warehouse";
return $csvrow;
}
function getAllSTSTProductsV2($language) {
$url = "https://api.stanleystella.com/webrequest/productsV2/get_json";
$jsonData = array(
'jsonrpc' => '2.0',
'method' => 'call',
'params' => array(
'db_name' => "production_api",
'password' => "YOUR_PASSWORD",
'user' => "YOUR_LOGIN",
"LanguageCode" => $language,
),