<?php

// www.google.de export filter

//titel /have
//beschreibung /have (description)
//link /have
//preis /have
//bild_url /have (image link)
//id /have
//waehrung nicht
//zustand /haben (condition)
//hersteller / have brand (they have it twice?)
//versand / have shipping
//gtin / dont have isn't set
//brand /have 
//googel product /have
//product type /have
//available /have
//mpn dont have

$data_array[] = array(
	'id',
	'availability',
 	'condition',
	'description',
	'product_type',
	'google_product_category',
	'link',
	'price',
	'title',
	'brand',
	'image_link',
	'manufacturer',
	'gtin'
//	'c:keywords:string',
//	'shipping'
);

foreach ($items as $article_obj) {

	if (is_array($images)) {
		$images = implode(',', $images);
	}

	$article_obj->short_description = str_replace('|',' - ', $article_obj->short_description);

	/*if ($article_obj->shop_bargain_price_1 > 0) {
		$article_obj->shop_price_1 = $article_obj->shop_bargain_price_1;
	}*/

	if ($article_obj->shop_price_1 > 0) {
		$data_array[] = array(
			$article_obj->id,
			'available for order',
			'new',
			csv_string($article_obj->short_description),
			csv_string($article_obj->structure_data->path_name),
			csv_string($article_obj->google_product_category),
			csv_string('http://'.$_SERVER['SERVER_NAME'].'/'.$article_obj->short_uri.'.html'),
			number_format($article_obj->shop_price_1, 2, ',', ''),
			csv_string($article_obj->name),
			csv_string($article_obj->manufacturer_text),
			csv_string('http://'.$_SERVER['SERVER_NAME'].'/web/'.SHOP_SYSTEM.'/images/article/'.$article_obj->file_name),
			'Intelectra',//csv_string($article_obj->manufacturer_text),
			csv_string($article_obj->ean_code),
			//csv_string($article_obj->seo_keywords),
			//'DE:::0.00'
		);
	}
}

function csv_string ($string) {
	$string = trim($string);
	$string = strip_tags($string);
	$string = str_replace('&auml;','ä',$string);
	$string = str_replace('&Auml;','Ä',$string);
	$string = str_replace('&ouml;','ö',$string);
	$string = str_replace('&Ouml;','Ö',$string);
	$string = str_replace('&uuml;','ü',$string);
	$string = str_replace('&Uuml;','Ü',$string);
	$string = str_replace('&szlig;','ß',$string);
	$string = str_replace('|',',',$string);
	//$string = str_replace(';',',',$string);
	$string = str_replace("\r\n",' ',$string);
	$string = str_replace("\n",' ',$string);
	return $string;
}

?>