->having(
'COUNT(*) ' . '<= 3 '
)
Hardcoded value 3 need to come From:
This is the query to return most viewed products biggest views number:
SELECT COUNT(report_event.object_id) FROM catalog_product_entity, report_event WHERE catalog_product_entity.entity_id = report_event.object_id GROUP BY catalog_product_entity.entity_id ORDER BY COUNT(report_event.object_id) DESC LIMIT 1
this number that query gives back needs to be multiplied by
$helper->getPopularProductPriority($storeId)
and the return of these actions should change the hardcoded number. Whats the best way to achieve this?
EDIT:
$priorityView = 3;
$lowerPriorityView = 2;
->having(
'COUNT(*) ' . '<= ? ',
$priorityView . 'AND' . ' COUNT(*) ' . '>= ? ',$lowerPriorityView
)
Xdebug query shows:
HAVING (COUNT(*) <= 3.000000 )
OR:
->having(
'COUNT(*) ' . '>= ? ',
$lowerPriorityView . ' AND ' . 'COUNT(*) ' . '<= ? ',$priorityView
)
returns:
HAVING (COUNT(*) >= '2 AND COUNT(*) <= ? ' )
Why is that?