Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Juni 22
3574
1
Apr. 22
2431
0
Feb. 22
4672
1
Jan. 22
2381
0
Juli 21
2707