). In order to make sure the code does not contains other HTML code it might be a good ideea to strip_tags() $prod_desc = smfeed_replace_not_in_tags("\n", "
", $prod_desc); $prod_desc = str_replace("\n", " ", $prod_desc); $prod_desc = str_replace("\r", "", $prod_desc); $prod_availability = str_replace("\n", " ", $prod_availability); $prod_availability = str_replace("\r", "", $prod_availability); // Clean product names and descriptions (separators) if ($datafeed_separator == "\t") { $prod_name = str_replace("\t", " ", strip_tags($prod_name)); $prod_desc = str_replace("\t", " ", $prod_desc); $prod_availability = str_replace("\t", " ", $prod_availability); } elseif ($datafeed_separator == "|") { $prod_name = str_replace("|", " ", strip_tags($prod_name)); $prod_desc = str_replace("|", " ", $prod_desc); $prod_availability = str_replace("|", " ", $prod_availability); } else { print "Incorrect columns separator."; exit; } $prod_url = smfeed_get_product_url($prod_id); $prod_image = smfeed_get_product_image($prod_image); // Here you can overwrite the default currency if your products are listed with different currencies // $datafeed_currency = $prod_currency // Required fields are: category name, merchant product ID, product name, product URL, product price // For the product model you should only use the manufacturer code, ISBN code or UPC code - If you are not sure about a field please leave it empty // Strip html from category name $cat_name = smfeed_html_to_text($cat_name); // Output the datafeed content // Category, Manufacturer, Model, ProdCode, ProdName, ProdDescription, ProdURL, ImageURL, Price, Currency, Shipping value, Availability, GTIN (UPC/EAN/ISBN) print $cat_name . $datafeed_separator . $prod_manufacturer . $datafeed_separator . $prod_model . $datafeed_separator . $prod_id . $datafeed_separator . $prod_name . $datafeed_separator . $prod_desc . $datafeed_separator . $prod_url . $datafeed_separator . $prod_image . $datafeed_separator . $prod_price . $datafeed_separator . $datafeed_currency . $datafeed_separator . $prod_shipping . $datafeed_separator . $prod_availability . $datafeed_separator . $prod_gtin . "\n"; } } else { print "Query error: " . mysql_error(); } // Function to return the Product URL based on your product ID function smfeed_get_product_url($prod_id){ return "http://www.example.com/product.php?id=" . $prod_id . "&utm_source=shopmania&utm_medium=cpc&utm_campaign=direct_link"; } // Function to return the Product Image based on your product image or optionally Product ID function smfeed_get_product_image($prod_image){ return "http://www.example.com/product_images/" . $prod_image . ".jpg"; } function smfeed_html_to_text($string){ $search = array ( "']*?>.*?'si", // Strip out javascript "'<[\/\!]*?[^<>]*?>'si", // Strip out html tags "'([\r\n])[\s]+'", // Strip out white space "'&(quot|#34);'i", // Replace html entities "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&(reg|#174);'i", "'™'i", "'•'i", "'—'i", ); // evaluate as php $replace = array ( " ", " ", "\\1", "\"", "&", "<", ">", " ", "¡", "¢", "£", "©", "®", "TM", "•", "-", ); $text = preg_replace ($search, $replace, $string); return $text; } function smfeed_replace_not_in_tags($find_str, $replace_str, $string) { $find = array($find_str); $replace = array($replace_str); preg_match_all('#[^>]+(?=<)|[^>]+$#', $string, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if (trim($val[0]) != "") { $string = str_replace($val[0], str_replace($find, $replace, $val[0]), $string); } } return $string; } ?>