You are here:  » Limit Returned Search Results

Support Forum



Limit Returned Search Results

Submitted by webie on Tue, 2007-10-09 16:21 in

Hi Dave,

Is there a way of returning the first 1000 products based on lowest price for the default search?

So if someone search for bosch freezer 1000 searches would be returned based on the lowest price first.

Many Thanks

Darren

Submitted by support on Tue, 2007-10-09 16:24

Hi Darren,

Do you actually want to display 1000 products on one page?

As it stands, all results are returned, paged by whatever value you have set for $config_resultsPerPage in your config.php.

Apologies if i've misunderstood...

Cheers,
David.

Submitted by webie on Wed, 2007-10-10 20:03

Hi David,

I was trying to work out when search.php searches the database for lets say freezer price tapestry will return all products in the database matching freezer?

Can we get search.php to return only 1000 results for freezer from the database based lowest price first?.

Many Thanks

Darren

Submitted by support on Wed, 2007-10-10 20:16

Hello Darren,

As it stands, the script does return all possible resuts for "freezer", limited by the value of $config_resultsPerPage in config.php.

It would be possible to add a limit of 1000 results to the code so that you never saw more than 1000 as the total number of results - let me know if this is what you want to do...

Cheers,
David.

Submitted by webie on Wed, 2007-10-10 23:10

Hi David,

This would great idea as i don't think most shoppers would ever browse through 1000 results?

Also we modified the search to pull back featured merchant first then the rest of the search results since i have imported over 2.8 million products this feature has stopped working in bargain shack but still works in my tool search site any idea dave on why this may have stopped working.

Can we have this based on lowest price? also i while ago you help out with keywords logging to stop and keywords with http in them not to log them in the database can we do the same for product reviews as well as i am getting a lot sex sites trying to post url back links as a product reviews i can manually delete them but i have over 50 last month

many thanks

Dave (do mind being called Dave or do you prefer David?)

All the best

Submitted by support on Thu, 2007-10-11 05:46

Hi Dave,

I'm still a little confused as to your first requirement - the script could be limited to 1000 results, but that would only have any effect if a user browsed to the 100th page (if $config_resultsPerPage is 10), and as you say it is unlikely anyone would ever go that far. The results are also based on lowest price by default - hense my confusion...!

Regarding ignoring reviews if they contain http, in reviews.php, look for the following code (line 12):

    if ($_POST["rating"] == $_POST["confirm"])

...and replace this with

    if (stripos($_POST["comments"],"http")!==FALSE) $ignore = true;
    if (($_POST["rating"] == $_POST["confirm"]) && !$ignore)

Cheers,
David.

Submitted by webie on Thu, 2007-10-11 17:43

Hi Dave,

Did you mean for reviews.php?

if (!isset($_POST["comments"])) $_POST["comments"] = "";

back to limit results to 1000 was an idea based on post i read about query the database for only the first 1000 revelvant searched keyword they where saying that google use this type of search. So if i have 2000 freezers in the database it would only pull back search results for the first 1000 freezers matched against lowest price desc? the idea was to put less load on the database to pull back queries faster? Maybe I read it wrong or just don't understand what it meant?.

Many Thanks
Darren

Submitted by support on Thu, 2007-10-11 17:46

Hi Darren,

In reviews.php, the line you posted stays - the modification goes immediately after it.

Regarding limiting the search to the first 1000 results, this won't make any difference with regards to performance because in order to sort by price the database has to scan the entire table anyway...

Cheers,
David.

Submitted by webie on Mon, 2007-10-15 01:40

Hi Dave,

Thanks for that small mod works a treat I will go with your proffensional view please except our apolgies from us non coders who come up with ideas which are waste of time it all big learning curve.

I did want to share this with other Price Tapestry users I had many products which where all in uppercase which I did not like I found this on the web this evening and applied it to searchresults.php and product.php it works well.

I though it be nice to share this as other may be havinng the same problem.

Function Part
--------------------
function convert2proper($strVal){
$iPos = 0;
$strValTmp = "";
do {
$iSpace = strpos($strVal," ", $iPos);
$strValTmp .= strtoupper(substr($strVal, $iPos, 1));
$strValTmp .= strtolower(substr($strVal, $iPos + 1, $iSpace - $iPos));
$iPos = $iSpace + 1;
} while(strpos($strVal," ", $iPos) != FALSE);
$strValTmp .= strtoupper(substr($strVal, $iPos, 1));
$strValTmp .= strtolower(substr($strVal, $iPos + 1));
return $strValTmp;
}
function cutString($strVal,$limit){
if(strlen($strVal)>$limit){
return substr($strVal,0,$limit) . "...";
}else{
return $strVal;
}
}

//Examples
//convert2proper("HI HOW ARE YOU?") returns "Hi How Are You?"

//cutString("superkallafragalistic",10) returns "superkalla..."

//Or both, which is what I use:

//cutString(convert2proper("HI HOW ARE YOU?"),10) which returns "Hi How Are..."
----------//Function end---------------------

Example for searchresults.php

$product["description"] = convert2proper($product["description"]);

Example for product.php

$mainProduct["description"] = convert2proper($mainProduct["description"]);

Hi hope this will help some users

Many thanks dave for all your help all the best

Darren