Hi,
I have a rss.php which has a link that goes to the product page at my pricetapestry site. How can I change it so it goes directly to the merchant site (tapestry_buyURL)?
I now have this:
print "<title>".$product["name"]." prijs ".$product["price"]." EUR</title>";
print "<link>".$baseURL.$config_baseHREF.$href."</link>";
print "<guid>".$baseURL.$config_baseHREF.$href."</guid>";
print "<description><![CDATA[";
print "<img src='".$product["image_url"]."' /><br />";
print "<p>".$product["description"]."</p>";
print "]]></description>";
print "</item>";
And if I want to include the merchant name in the description?
print "<p>".$product["description"]."</p>";
I tried this:
print "<p>".$product["description"]." ".$product["merchant"]."</p>";
Hi Marco,
That looks fine, so it would indicate that the merchant field has not been selected by the SQL; could you post the $sql="..." line from your RSS script and I'll take a look (or post the entire file if you're not sure, i'll cut it down before publishing your reply)...
Cheers,
David.
--
PriceTapestry.com
Here is the sql for the merchant field.
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ".$where." ORDER BY RAND() LIMIT 20";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
print "<item>";
if ($config_useRewrite)
{
$href = "product/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$href = "products.php?q=".urlencode($product["name"]);
}
I was also thinking about a not so random rss. Is there a variant possible so that it gets the articles from a specific Category within a specific price range and ordered by price (ascending)?
Hi Marco,
It's performing a SELECT *, so $product["merchant"] should definitely be in scope - double check the output to see if it's appearing now and not a transient FTP issue for example.
You can modify the WHERE clause to the SELECT by whatever criteria your require; for example by specific category; insert before the above code (replacing your existing $where = "..." line):
$where = " category='Category Name' ";
...or for a price range:
$where = " price BETWEEN 100.00 AND 200.00
In the latter, replace "ORDER BY RAND()" from the SQL with "ORDER BY PRICE ASC"
Cheers,
David.
--
PriceTapestry.com
Hi,
Tried replacing
Simply replace these lines:
print "<link>".$baseURL.$config_baseHREF.$href."</link>";
print "<guid>".$baseURL.$config_baseHREF.$href."</guid>";
print "<link>".$product["buy_url"]."</link>";
print "<guid>".$product["buy_url"]."</guid>";
error on line 1 at column 291: EntityRef: expecting ';'
Below is a rendering of the page up to the first error.
I also tried the new WHERE clause but I think I'm missing something as I get this warning:
: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
/home/mode/public_html/includes/database.php
The where clause I tried is:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ".$where = "category='Desigual' ORDER BY PRICE ASC LIMIT 20";
For your reference the total rssdirect.php for the direct link (without the modified where clause):
<?php
$baseURL = "http://www.merkenmerken.nl"; // URL of your site without trailing "/"
require("includes/common.php");
$config_baseHREF = "/";
header("Content-Type: text/xml");
print "<?xml version='1.0' encoding='UTF-8'?>";
print "<rss version='2.0'>";
print "<channel>";
print "<title>RSS feed merkenmerken.nl</title>";
print "<link>".$baseURL.$config_baseHREF."</link>";
print "<description>RSS feed merkenmerken.nl</description>";
if ($_GET["merchant"]) { $where = " WHERE merchant='".database_safe($_GET["merchant"])."' "; }
elseif ($_GET["category"]) { $where = " WHERE category='".database_safe($_GET["category"])."' "; }
elseif ($_GET["brand"]) { $where = " WHERE brand='".database_safe($_GET["brand"])."' "; }
else { $where = ""; }
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ".$where." ORDER BY RAND() LIMIT 20";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
print "<item>";
if ($config_useRewrite)
{
$href = "product/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$href = "products.php?q=".urlencode($product["name"]);
}
print "<title>".$product["name"]." prijs ".$product["price"]." EUR</title>";
print "<link>".$product["buy_url"]."</link>";
print "<guid>".$product["buy_url"]."</guid>";
print "<description><![CDATA[";
print "<img src='".$product["image_url"]."' /><br />";
print "<p>".$product["description"]."</p>";
print "]]></description>";
print "</item>";
}
}
print "</channel>";
print "</rss>";
Hi Marco,
The entity warnings will be because the URLs being included in the link and guid elements will already contain HTML entities, so the best thing to do is to CDATA those elements as follows:
print "<link><![CDATA[".$product["buy_url"]."]]></link>";
print "<guid><![CDATA[".$product["buy_url"]."]]></guid>";
Regarding the SQL, no need for the $where variable when specifying the entire clause within the string (rather than in a separate $where variable), so have a go with just:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE category='Desigual' ORDER BY PRICE ASC LIMIT 20";
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi Macro,
Simply replace these lines:
print "<link>".$baseURL.$config_baseHREF.$href."</link>";
print "<guid>".$baseURL.$config_baseHREF.$href."</guid>";
...with:
print "<link>".$product["buy_url"]."</link>";
print "<guid>".$product["buy_url"]."</guid>";
Cheers,
David.
--
PriceTapestry.com