Skip to Content
Menu
This question has been flagged

Hi,

I am trying to change the _get_search_domain() which is used in search on website. I have added some extra attributes to products and I want to search by all of them. I am doing this by extending the domain that is returned from the function. When there are multiple words in search I want to order them so that if there are any records that match the  first condition they have to be returned first.  

The domain is created for each word as (search="bike green"):

['&', '|', '|', '|', 
​('name', 'ilike', "bike"), ('description', 'ilike', "bike"),
​('attribute_desc.text', 'ilike', "bike"),
​'|', '|', '|',
​('name', 'ilike', "green"), ('description', 'ilike', "green"),
​('attribute_desc.text', 'ilike', "green")
]

So i wanted to order them if the record matches the first AND they are first in return if they match second condition in AND they go to the back of returned products.

I saw you could do this in SQL with the THEN 1 or THEN 2 but dont know how to use that here. If there is any other way preferably from the domain rather than orderby.

Thank you all.

Avatar
Discard
Related Posts Replies Views Activity
2
Jun 22
3436
1
Apr 22
2305
0
Feb 22
4602
1
Jan 22
2272
0
Jul 21
2628