You are here:  » Limit the number of results shown

Support Forum



Limit the number of results shown

Submitted by Paul1107 on Tue, 2010-01-05 15:17 in

Hi David,

Happy New Year! I hope that 2010 is a prosperous one for you and all your customers, especially ME!

As I work in Wordpress mostly, I wonder whether there is a way of limiting the number results that are shown in post such as 10 or 12 for example, as I use the following calling code in posts, the number of results are sometime verbose with lots of products results which can span across lots of pages. I would quite like the idea of showing say the top 10 best selling ideas from say a merchant, or of a particular type of product.

I suspect it wowuld be through using an sql query and the LIMIT statement, but don't know how to incorporate it? I hoped you could help.

My current calling code...

<?php if (!$_GET["product"]): ?>
<div id="pricehi-lo">
  <a href="?maxPrice=30.00">Under &pound;30</a> |
  <a href="?minPrice=30.00&maxPrice=50.00">&pound;30 - &pound;50</a> |
  <a href="?minPrice=50.00&maxPrice=100.00">&pound;50 - &pound;100</a> |
  <a href="?minPrice=100.00&maxPrice=200.00">&pound;100 - &pound;200</a> |
  <a href="?minPrice=200.00">Over &pound;200</a> |
  <a href="?sort=priceAsc">Price - Low to High</a> |
  <a href="?sort=priceDesc">Price - High to Low</a>
</div><br/>
<?php endif; ?>
<?php
 $external_baseHREF = "{link saved}";
 $external_path = "{code saved}";
 if (!$_GET["q"] && !$_GET["r"] && !$_GET["merchant"])
 {
  $_GET["q"] = "category:PT Summerdresses,BeachSkirts and Dresses,Day Dresses,GODDIVA UNIQUE,CELEBRITY DRESSES,Maxi Dresses,Casual Dress,Home Dresses All Dresses,Home Dresses 10 Off Dresses";
   if (!$_GET["sort"]) $_GET["sort"] = "priceDesc";
   if (!$_GET["minPrice"]) $_GET["minPrice"] = "20.00";
   if (!$_GET["maxPrice"]) $_GET["maxPrice"] = "1000.00";
 }
 require($external_path."external.php");
?>

Thanks again

Paul

Submitted by support on Tue, 2010-01-05 15:28

Hi Paul,

Happy new year likewise!

That should be straight forward to plumb in. First, add a new variable to your calling code (on the line before external.php is called), e.g.:

  $external_maxResults = 10;

And then in your external.php, look for the following code around about line 502:

$resultCount = $rows[0]["resultcount"];

...and REPLACE that with:

$resultCount = $rows[0]["resultcount"];
if ($external_maxResults)
{
  if ($resultCount > $external_maxResults) $resultCount = $external_maxResults;
}

Note that hf $external_maxResults is less than or equal to your $config_resultsPerPage setting then the navigation bar will not be displayed which may be the effect you're after.

Hope this helps!

Cheers,
David.

Submitted by Paul1107 on Tue, 2010-01-05 15:45

Hi david,

Thanks for this

I have updated the extermal.php and used the calling code below:

<?php
 $external_baseHREF 
"http://www.s229581664.websitehome.co.uk/mystore/";
 
$external_path "/kunden/homepages/45/d229581650/htdocs/mystore/";
 if (!
$_GET["q"] && !$_GET["r"] && !$_GET["merchant"])
 {
  
$_GET["q"] = "category:PT Summerdresses,BeachSkirts and Dresses,Day Dresses,GODDIVA UNIQUE,CELEBRITY DRESSES,Maxi Dresses,Casual Dress,Home Dresses All Dresses,Home Dresses 10 Off Dresses";
   if (!
$_GET["sort"]) $_GET["sort"] = "priceDesc";
   if (!
$_GET["minPrice"]) $_GET["minPrice"] = "20.00";
   if (!
$_GET["maxPrice"]) $_GET["maxPrice"] = "1000.00";
 }
 
$external_maxResults 10;
 require(
$external_path."external.php");
?>

Though I get a result, I get 8 x 3 rows of results rather than the 10 requested?

Any ideas please?

Paul

Submitted by support on Tue, 2010-01-05 16:13

Hi Paul,

Ah - a little more code required sorry - in place of the modification described above, use:

$resultCount = $rows[0]["resultcount"];
if ($external_maxResults)
{
  if ($resultCount > $external_maxResults)
  {
    $resultCount = $external_maxResults;
    $sql = str_replace($offset.",".$config_resultsPerPage,$external_maxResults,$sql);
  }
}

Cheers,
David.

Submitted by Paul1107 on Tue, 2010-01-05 16:18

Hi Daavid,

Perfecto! works a treat.

Thanks Again

Paaul