Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1649 Visualizzazioni

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
giu 22
3591
1
apr 22
2444
0
feb 22
4689
1
gen 22
2399
0
lug 21
2712