I’m curious about how I can modify the algorithm/query of the Related Listings carrousel shown on the single listing page.
Right now, it seems a bit incomplete; for example, let’s say I have 3 items from the same category listed on the site and 2 of them have their main attribute (the brand) identical. In such a case, if I open one of the two which have the same brand, then the only related listing I see for that one is the third listing from the same category which has a different brand (so only one item shown, and not even the closest one).
The example is not that relevant though, as I would like to play a bit further with it. Therefore, could you please let me know where is the code responsible of this behaviour, or how I can change it?
A no-code solution for modifying the related listings would be to select the available option under HivePress > Settings > Listings and enable the Related option for the specific attribute in the attribute settings under the Display section.
It all depends on the type of the attribute. If it’s a select attribute, you need to add two underscores and an ID, for example, __id(), because get_material alone will return an array of objects.
Thanks a lot for the detailed answer → I was aware of the Related option in the attribute settings, but I didn’t fully understand how it works so far.
Now I get it - it acts as an “AND”, not an “OR” (As I initially believed). Would have been lovely to have an “OR” with variable weights, but for now I can work with it as it is.
Thanks for your feedback – we’ll consider adding more UI options for the related listings query logic. In the current version, it may still be possible, but with the code customizations (by overriding the meta_query via the hivepress/v1/models/listing/relate hook).