Hello David, hope you are well!
I am currently using the script for a very niche website with around 20 products on it. I compare prices with around 11 or so retailers and probably 80% of the products show at least 8 or more retailers when comparing products.
But some retailers don't stock certain products, and I have a couple of products with just 1 or 2 retailers showing in the price comparison. (which could make the customer possibly look around)
I was wondering if it was possible to show every retailer I have datafeeds for, even if they do not stock the item, and have them listed at the bottom with 'not stocked' for example.
I have created all my datafeeds manually, so I can add each of the 20 models into each retailers feed no problem.
I'm guessing it could be as simple as if the value of the product not stocked is '0' in the datafeed, then it displays that retailer with 'not stocked' ??
Any help would be appreciated, but if its a big job then its not majority important!
Cheers
Hi,
Since the database does not hold generic URLs, the only "difficulty" with this is managing your links to the merchants that do not stock the product being viewed - however with only 11 merchants this should be manageable using an array within a modified html/prices.php. I think the entire mod can be made in that one file to keep things simple. Modify the $genericURL array at the top, replacing "Merchant A" etc. and the URLs with the generic URLs for each of your merchants. The merchant name must match exactly the merchant name as registered in the site.
The additional code at the bottom of this new prices.php will then query the feeds table to get a list of all merchants, and then extend the prices table creating a line for each merchant that was not featured in the main prices table above (by using the $hasProduct array). Here you can of course change the text "Not Stocked" as required; and as it stands the merchant name will be a link to the merchant index on your site (just as in the main table), with the "Visit Store" link being a link to the generic URL as contained in the $genericURL array for that merchant...!
<?php
$genericURL["Merchant A"] = "http://www.example.com/";
$genericURL["Merchant B"] = "http://www.example.org/";
$genericURL["Merchant C"] = "http://www.example.net/";
?>
<div class='prices'>
<table width='100%' cellpadding='4'>
<tr bgcolor='#eeeeee'>
<th width='200' align='left'><?php print translate("Stockist"); ?></th>
<th align='left'><?php print translate("Catalogue Product Name"); ?></th>
<th align='left'><?php print translate("Price"); ?></th>
<th align='left'> </th>
</tr>
<?php foreach($prices["products"] as $product): ?>
<?php $hasProduct[$product["merchant"]] = TRUE; ?>
<tr bgcolor='#ffffcc'>
<td><a href='<?php print $product["merchantHREF"]; ?>'><?php print $product["merchant"]; ?></a></td>
<td><?php print $product["name"]; ?></td>
<td><strong><?php print $config_currencyHTML.$product["price"]; ?></strong></td>
<td align='center'><a href='<?php print tapestry_buyURL($product); ?>' <?php print javascript_statusBar("go to ".$product["merchant"]); ?>><?php print translate("Visit Store"); ?></a></td>
</tr>
<?php endforeach; ?>
<?php
$sql = "SELECT * FROM feeds ORDER BY merchant";
database_querySelect($sql,$feeds);
foreach($feeds as $feed)
{
if (!$hasProduct[$feed["merchant"]])
{
if ($config_useRewrite)
{
$feed["merchantHREF"] = $config_baseHREF."merchant/".tapestry_hyphenate($feed["merchant"])."/";
}
else
{
$feed["merchantHREF"] = $config_baseHREF."search.php?q=merchant:".urlencode($feed["merchant"]);
}
?>
<tr bgcolor='#ffffcc'>
<td><a href='<?php print $feed["merchantHREF"]; ?>'><?php print $feed["merchant"]; ?></a></td>
<td>Not Stocked</td>
<td> </td>
<td align='center'><a href='".$genericURL[$feed["merchant"]]."'>Visit Store</a></td>
</tr>
<?php
}
}
?>
</table>
</div>
Hope this helps! Any problems if you could email me your modified html/prices.php so that I can see exactly what you're working with i'll take it from there...
Cheers,
David.
Thanks a lot for your help David, I will give this a go today! Sorry for the delay in replying!
Cheers!!
Hi David,
Trying to implement this and mod, but want to display merchant logos instead of text.
Using the following code
<?php
if (file_exists("/home/.........logos/".$product["merchant"]))
{
print "<a href='".tapestry_buyURL($product)."' target='_blank'><img class='logoborder' img border='0' src='http://www..........logos/".$product["merchant"]."' alt='".$product["name"]."' /></a>";
}
else
{
print " ";
}
?>
When I replace
<?php
print $feed["merchant"];
?>
Can you advise on what to change.
Thanks
Adiran
Hi Adrian,
Within your logo code, you would need to replace each instance of $product with $feed
- that should be all it is, e.g.
<?php
if (file_exists("/home/.........logos/".$feed["merchant"]))
{
print "<img class='logoborder' border='0' src='http://www..........logos/".$feed["merchant"]."' />";
}
else
{
print " ";
}
?>
Cheers,
David.
--
PriceTapestry.com
Thanks David,
Should have spotted that !!
Cheers
Adrian
Hi,
Do you have a straight forward merchant URL for the retailers in your database at all? This is relatively straight forward; but I'm assuming that you would want some kind of link to the retailers that don't stock the product...
Cheers,
David.