Přejít na obsah
Menu
You need to be registered to interact with the community.
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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
čvn 22
3509
1
dub 22
2362
0
úno 22
4626
1
led 22
2331
0
čvc 21
2671