I'd like to make an improvement to how I'm displaying related products on a product detail page. Right now, the list of related products will...
- be limited to the same type and category (Playa relationships)
- be ordered by dollar value in descending order (numeric field)
Sometimes the price alone can make an item dissimilar; for example a $1.5M gum production machine isn't relevant on the detail page for a $0.75 pack of gum. What I'd like to do is limit my related entries to anything within ${x} of the current item.
Here's the (simplified) related products template, to which I pass the IDs of related category pages:
<h3>Related Products</h3>
<ul>
{exp:playa:parents entry_id="{embed:category_ids}" orderby="product_price" sort="desc"}
<li><a href="{page_uri}">{title}</a>, ${product_price}</li>
{/exp:playa:parents}
</ul>
If I wanted to limit by date, I could use EE's start_on
parameter. If I wanted to match a specific value, I know I could use the search
paramater. In this case, I simply want to add WHERE product_price <= x
, with x
being a dollar amount I've already calculated in PHP to be reasonably close to the currently-viewed product. Is there a way to accomplish this without going straight for the query module?