View Full Version : Price sorting added to the simple query
prosperent brian
12-01-2011, 08:25 AM
Yesterday the ability to sort by price and sale price was added to the simple api queries. More info is available in the docs of course, but it's pretty basic:
sortPrice (Optional)
sortPrice=DESC (Acceptable values are DESC OR ASC. This would sort the results by price in descending order)
and
sortPriceSale (Optional)
sortPriceSale=DESC (Acceptable values are DESC OR ASC. This would sort the results by price in descending order)
Now, you guys no longer have to use extended queries for price sorts, which means your product results will be more relevant, and cleaner since they go through our algorithm.
Would it be possible to have the highest price in the data set and the lowest price in the data set given to us within the other API information ? It's easy enough to find the highest and lowest price within the 500 returned results, however, because pricing information is confined to only those 500 results, there could be other products outside of the range defined through those 500 items.
For example, if I'm searching for "Dallas Cowboys," I see that there are 16605 total results, and the lowest price is $14.99 and the highest price is $249.99. Now that price range is valid for the 500 returned results alone.
However, if I send different pricing filters for the same query, thus telling the API to give me results within the newly defined price range, (say from $0.00 to $5.00), I'm seeing 118 products with the lowest price being $1.95.
And again, if I adjust the price ranges from $3000 to $10000, the product with the highest price is now $4727.99 .
So it can be said that the price ranges for "Dallas Cowboys" are from $1.95 to $4727.99 over the span of 16605 total products.
Now if this information were available to me from the beginning, I could code in some variable price ranges that would showcase all possible products across all price ranges (without ever having to toss up an error page because a price range was specified outside of the entire scope of price ranges ... like if someone were to specify a price range of min=10000 max=20000 for the "dallas cowboys" query )...
I understand that I could code in variable price increments already, although the price increments would happen at random, and might possibly violate the acceptable range of prices across all products, for example like this: $lowfilter = $lowest_price ; $highfilter = $lowest_price * 1.25 ;
Of course this request of mine isn't a big deal in the first place because I'm doing NOINDEX on my error page and on my general search page ... therefore the search engines would not archive invalid searches in the first place. However, it would be helpful in that I could structure my queries in such a manner that the highest price would never be greater than the highest price across all products.
prosperent brian
12-03-2011, 08:39 PM
Unfortunately, you can't actually query a search engine in that way. You are able to get the total records easily because you are searching the corpus for the occurances of each word, but you can't get specif details about each record without pulling all of the data for each one. We would literally have to pull the data for all 16K records into memory, sort them, then send back the first X results. WAY too expensive memory wise.
Ok, not a problem at all. I have a couple of ways to make this work on my end. Thanks for considering! :)
Nathan Malone
12-04-2011, 06:02 AM
Is it live now? The following test query isn't returning sorted results:
$prosperent = new Model_Prosperent(array(
'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'query' => 'black shoes',
'sortPrice' => 'ASC',
'page' => 1,
'limit' => 10,
));
$prosperent->fetch();
print_r($prosperent->getAllData());
BTW, yes, I updated the class to the latest version.
AcidRaZor
12-05-2011, 12:50 AM
Don't give the user a price range they can fill in themselves. Just give them an option to sort by lowest/highest price
Prosperent Mike
12-05-2011, 08:34 AM
@Nathan Malone, an update was just released to the Prosperent_Api class that supports the sortPrice and sortPriceSale.
Strykerraven
12-05-2011, 10:24 AM
Yay, Looks like it's live now. :D
prosperent brian
12-05-2011, 10:29 AM
Haha, were you just sitting there hitting refresh? It is live. Pushed out about the same time you posted :)
Strykerraven
12-05-2011, 10:49 AM
Haha no, Good timing :D
Though I have been busy clicking... (finally got redirects to work correctly in a php switch)
Impressions 2
Clicks 30
CTR 1,500.00%
Powered by vBulletin™ Version 4.0.8 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.