Hi David,
Happy new Year.
Is there a way to show compare prices in the search results even if the the search has been filtered by a merchant.
Example links:
Link 1 - No merchant specified, shows compare prices
http://www.example.com/shopping/?pto_q=bw%253A&pto_merchantFilter=&pto_categoryFilter=Televisions&pto_brandFilter=LG&pto_minPrice=329.00&pto_maxPrice=11999.00&log=1
Link 2 - Merchant specified, won't show compare prices.
http://www.example.com/shopping/?pto_q=bw%253A&pto_merchantFilter=Currys&pto_categoryFilter=Televisions&pto_brandFilter=LG&pto_minPrice=349.00&pto_maxPrice=11999.00&log=1
Take it theres a simple mod for that?
Regards,
Sean
Hello Sean,
Sure - to requery numMerchants and minPrice for results where numMerchants is 1 (by way of index search or filter application), edit pto_search.php and look for the following code at line 39:
$pto_searchSelect = "SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice";
...and REPLACE with:
$pto_searchSelect = "SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice,name";
And then the following code at line 373:
if ($pto_searchResultsTo > $pto_searchResultsTotal) $pto_searchResultsTo = $pto_searchResultsTotal;
...and REPLACE with:
if ($pto_searchResultsTo > $pto_searchResultsTotal) $pto_searchResultsTo = $pto_searchResultsTotal;
$names = array();
foreach($pto_searchResults as $row)
{
if ($row->numMerchants == 1)
{
$names[] = "'".esc_sql($row->name)."'";
}
}
if (count($names))
{
$in = implode(",",$names);
$sql2 = "SELECT name,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$pto_config_databaseTablePrefix."products` WHERE name IN (".$in.") GROUP BY search_name";
$wpdb->query($sql2);
$rows2 = $wpdb->last_result;
$requery = array();
foreach($rows2 as $row2)
{
$requery[$row2->name] = $row2;
}
}
And finally the following code at (now) line 429:
$pto_searchResults[$k]->rating = $rows3[$product->id]->rating;
...and REPLACE with:
$pto_searchResults[$k]->rating = $rows3[$product->id]->rating;
$pto_searchResults[$k]->rating = $rows3[$product->id]->rating;
if ($product->numMerchants == 1)
{
$pto_searchResults[$k]->numMerchants = $requery[$product->name]->numMerchants;
$pto_searchResults[$k]->minPrice = $requery[$product->name]->minPrice;
}
Cheers,
David.
--
PriceTapestry.com