| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | Mark Forums Read | User manuals | Login |
Front end (Customer) product search logic and search results - worse than X-Cart 4? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Front end (Customer) product search logic and search results - worse than X-Cart 4?
Just having a tinker with X-Cart 5.4 code. As far as I see in the code for customer searches:
I've hacked it like this: PHP Code:
But that's two calls to the database instead of one. In X-Cart 4 the basic query called everything and then you could manipulate or get data from the array very easily. So if I wanted to have a page title that said: Search for 'apple': cheapest product is Apple Ipod, costs $800 That was pretty easy. In X-Cart 5 it looks like a lot of coding will be needed or have I missed something?
__________________
Verion 4.7.12 |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Front end (Customer) product search logic and search results - worse than X-Cart 4?
You shouldn't be doing this. Find the code that calls getData - this will pass to the function the conditions ($cnd variable). Find the function that sets conditions - there is one, I don't remember the name of it though. Decorate the function doing this in your module to get parent and add to conditions your new condition. This way getData will receive the adjusted $cnd variable and do the search as needed and run one query - you do not have to decorate the getData function..
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#3
|
|||||||
|
|||||||
Re: Front end (Customer) product search logic and search results - worse than X-Cart 4?
Yes - I agree with you. It should be a module (and it will be) but just tinkering.
However this would not change the overall outcome. I would need to call GetData with byTitle set to 'Y' and then call it again with byTitle set to 'NULL'. That's two database calls. Better would be one call which also collects all product info such as the name, description, attributes, etc. Then manipulate this array as needed. The other issue is that getData is only called after the <head> area has been executed (it is called by getPageData). That's too late if you want to include specific info about a product (say the cheapest one) in the <title> or meta description. So I'm thinking: how to call getPageData at the beginning (in the controller) and then change the twig so it only calls getPageData if a particular array (this.getPageData()) is empty (i.e. the function has not already been called)
__________________
Verion 4.7.12 |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Front end (Customer) product search logic and search results - worse than X-Cart 4?
Im not sure what you are trying to do there and why do you have to call the query twice - with value and null.
You can do a search where "term" is in product name or product description. Then loop through the result and sort as needed. No need of 2 queries.
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#5
|
|||||||
|
|||||||
Re: Front end (Customer) product search logic and search results - worse than X-Cart 4?
So what I am trying to do is for any search term:
- list products where the substring is in the product title first - list products where the substring is elsewhere (like in the description) after the above. If I do a getData (using the default code) it returns a list of products but that list does not contain the name, description, page title, meta description, etc. As such I can't loop through these results to get places where the substring appears in the product title (in order to list those first) and then tag the left overs onto that array. ... or can I?
__________________
Verion 4.7.12 |
|||||||
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|