FOS Elastic range price with discount

I want to get all the products by range price with discount.

this is what it looks like in sql:

  WHERE (
CASE WHEN p.discount IS NOT NULL THEN ROUND(
  p.unit_price * (100 - p.discount) / 100, 1) 
ELSE p0_.unit_price END ) >= :min 
  AND (
    CASE WHEN p.discount IS NOT NULL THEN ROUND(
      p.unit_price * (100 - p.discount) / 100, 1) 
    ELSE p0_.unit_price END ) <= :max 

is there a way to do the same with range condition?

$fieldRange = new ElasticaQueryRange('unitPrice', array('gte' => 300, 'lte' => 1500));

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *