Hello everybody
Various price comparison search engine provide to its customers:
a list of brands and merchants returned by the search.
I would like to know how make this in Price tapestry?
Anyone can help me?
Thank you
Guillaume
thank you David
It 's work perfectly
Best regards
Guillaume
Thank you
Now, I would like to make a drop down list for the brands and price braket
Can you show me how to do this
Thank you
Guillaume
Hmm... This mod lists ONLY brands/merchants for the current page...
Lets say there are 100 results spread across 10 pages (10 results a page). The 100 products come from brands: A, B, C, D, E, F, G. - Now with this mod, page one will list products from brands A and B while page 2 will list products from brands A, C and D (corresponding to the products on the current page)
Question is : How can I list ALL the brands from ALL products that match the term?
Thanks
Hi Pasha,
The code we were discussing in this thread...
http://www.pricetapestry.com/node/2307
...should SELECT all categories and brands for the current search. Would that method be more suitable?
Cheers,
David.
Yes but the code we were discussing does not work... - It gives
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /xxxxxxxxxxx/xxxxxxxxxxx/includes/database.php on line 21
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /xxxxxxxxxxx/xxxxxxxxxxx/includes/database.php on line 26
errors, so I tried to tinker with it myself and now I have exactly the same results as if the mode above were applied - only categories for the current page...
Any other ideas how to select all categories for the products returned when searched?
Thanks a lot in advance.
Hi Pasha,
This should be straight forward but may have performance implication on a much larger site. Could you perhaps email me your modified search.php and i'll try it out on my test server and get something working for you...
Cheers,
David.
Hello Guillaume,
This can be done in a very similar way to your price bracket code. All that's needed is a loop through the search results array immediately after the query, building up an array of the brands and merchants included. The easiest way to build up a unique list of use the merchant/brand as they key of an associative array.
Currently in search.php, you will find the following code on line 160:
$searchresults["products"] = $rows;
AFTER this line, add the following new code to build up the arrays:
$merchants = array();
$brands = array();
foreach($searchresults["products"] as $s)
{
$merchants[$s["merchant"]] = 1;
if ($s["brand"]) $brands[$s["brand"]] = 1;
}
You can now use the $merchants and $brands array to generate your lists, for example you could add the following code just before the line to include html/searchresults.php to display a list of the included merchants:
print "These results feature products from:";
print "<ul>";
foreach($merchants as $merchant => $v)
{
$href = $config_baseHREF."search.php?q=merchant:".urlencode($merchant);
print "<li><a href='".$href."'>".$merchant."</a></li>";
}
print "</ul>";
...or for brands:
print "These results feature the following brands:";
print "<ul>";
foreach($brands as $brand => $v)
{
$href = $config_baseHREF."search.php?q=brand:".urlencode($brand);
print "<li><a href='".$href."'>".$brand."</a></li>";
}
print "</ul>";
Hope this helps!
Cheers,
David.