I am trying to put a search by price section in to the code.
i was going to sort the price feild in the DB and add the code to serach - But I am totaly stuck !!
Price
Under £99
£99 - £199
£200 - £299
etc
Any help..
David,
I havenet a clue about SQL as you know.
PHPMYADMIN via cpanel
Bear with me Eddie; you'll basically need the whole code to do this if you have no SQL experience and limited PHP knowledge (there's some tricky code required to parse the price range section). I'm busy for most of today but will try and get something for you later...
Hi Eddie;
Not had a chance to get onto this today i'm afraid - AutoSitemap.com is having some database issues (actually, about 150 database issues per second to be more precise :o) but I think i'm on top of that now and should be able to have a look at this tomorrow.
Is this now off your list David? I know you have been busy - refering to your comments on the "Pro Version License cost & date"
Hi Eddie,
Not at all - it's very much on the list. Filters (primarily including break-down by price) are what i'm working on at the moment and what will then become the "Pro" version.
Price search implementation as a query format (e.g. price:0-199:keyword) didn't cut it functionality wise; so i'm now working on improving the database structure and query strategy so that this can be done efficiently as a filter on another index; enabling you, for example, to search on Fridges from £100-£299.
The basics are straight forward; but I need to release something that is going to have acceptable performance on a dataset of thousands of products.
David - Cool (I was just asking!)
I think the price search should be used as a filter due to the large number of products.
e.g - if you had searched for widgets you can then display oly the widgets under xxx
On another site I use I have the following code in a config.php file - and then call it as a function :
$aPriceRange = array();
$aPriceRange[0] = array('Under £99', 0, 99);
$aPriceRange[1] = array('From £99 to £149', 99.01, 149);
$aPriceRange[2] = array('From £149 to £199', 149.01, 199);
$aPriceRange[3] = array('From £199 to £299', 199.01, 299);
$aPriceRange[4] = array('Over £299', 299.01, 12000);
It's kinda nice to make the price range options dynamic based on the overall price range of the initial query.
For example, if you search on "Plasma Screen TVs" price range might start with "Under £500"; whereas if your search was for "Microwave Oven" you would get "Under £50"...
Couldnt you have a preset choice, say:
under £149
Under £ 299
Under £399
etc
and then only echo the price range if availible in the DB.
The results would be right if say the maximum price in the range was only £ 169 with:
under £149
Under £ 299
being diplayed!
That's more or less what i'm referring to. You make the initial query, and then look at the minimum and maximum price returned. Then you can automatically generate sensible price bands to cover that range.
Hi David,
Did this get any further or any code written? I'd be interested in seeing it if you have.
Thanks
Dave
Hi Dave,
This isn't something i've progressed as it really does become quite complex and many users would be disappointed with the results based on the quality of information available. I think it would work - but only in a small number of use cases.
Cheers,
David.
Firstly, the price field is not indexed, so you will have to create an index on price if you want to do this with any reasonable level of performance.
Are you running phpMyAdmin or Webmin on your server and can access the database that way? Then I can instruct you on creating an index.
Then, the way to implement this would be to create a query format along the lines of:
"price:0-99:"
..and then create a case "price" within search.php where you can see similar code for case "merchant", case "brand" etc.
That code will have to parse the second component of the broken down query format into the two numbers, min AND max, and then construct an SQL statement using the BETWEEN operator, so you're aiming for something like this:
SELECT * FROM products WHERE price BETWEEN $min AND $max;
You might want to change the order parameter from the product name to price of course; and make sure to keep the same LIMIT criteria to avoid a massive SQL result...!