EXporting data from pricetapestry
Hello David
I would like to be able to export the data/products from pricetapestry, is that possible.
as a .csv file, comma seperated feeds with the standard fields.
Would it be possible if 2 or more items are the same, that the descriptions are compiled so only one item is added to the export with the cheapest price shown?
Thanks alot Mally
Mally
Hello David, thanks very much.
I've tried the above but the description field is been spread over several fields on some occasions and is not showing the descriptions from all the mmerchants...
The rest of the fields are working correctly though!
Cheers
Mally
Hi Mally,
Could you email me a sample of the output where it has gone wrong - I can't see anything obviously wrong so must be a bit more subtle....!
Cheers,
David.
--
Developer, Price Tapestry
For unrelated PHP, MySQL or Affiliate Marketing tech help please post your questions on my personal forum
Hi mally,
The basics of exporting are covered in this thread:
http://www.pricetapestry.com/node/506
To collate by product name with a combined description is a bit trickier, but have a go with this for starters (run from the main Price Tapestry directory);
export.php
<?phpset_time_limit(0);
require("includes/common.php");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=products.csv");
$baseUrl = "http://".$_SERVER["HTTP_HOST"].$config_baseHREF;
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY name,price ASC";
$link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
@mysql_select_db($config_databaseName,$link);
$result = mysql_unbuffered_query($sql,$link);
print "Merchant,Name,Description,ImageURL,BuyURL,Price,Category,Brand\n";
function add_row($row,$description)
{
if ($config_useRewrite)
{
$url = $baseUrl."product/".urlencode(str_replace(" ","-",$row["name"])).".html";
}
else
{
$url = $baseUrl."products.php?q=".urlencode($row["name"]);
}
print $row["merchant"].",";
print $row["name"].",";
print trim($description).",";
print $row["image_url"].",";
print $url.",";
print $row["price"].",";
print $row["category"].",";
print $row["brand"]."\n";
}
while($product = mysql_fetch_array($result,MYSQL_ASSOC))
{
// make product data safe for CSV output
foreach($product as $k => $v)
{
$product[$k] = str_replace(","," ",$v);
$product[$k] = str_replace("\n"," ",$v);
$product[$k] = str_replace("\r"," ",$v);
}
if ($last_product && ($product["name"] <> $last_product))
{
add_row($last_row,$description);
$description = "";
}
$description .= $product["description"]." ";
$last_product = $product["name"];
$last_row = $product;
}
add_row($last_row,$description);
?>
Cheers,
David.
--
Developer, Price Tapestry
For unrelated PHP, MySQL or Affiliate Marketing tech help please post your questions on my personal forum