Hey,
I want to return products to be displayed on my category page between 2 price ranges. I have managed to get this working without a product having a special but not with. All code in the controller and view pages work fine, it's just the model.
This is the code I use within the getProducts method.
Code: Select all
if (!empty($data["PriceLow"]) && !empty($data["PriceHigh"])) {
$sql .= " AND (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END) >='". $data["PriceLow"] ." ' AND (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END) <='". $data["PriceHigh"] ."'" ; }
Without the case it's prefect.
Also, when it works without the special using the following code:
Code: Select all
if (!empty($data["PriceLow"]) && !empty($data["PriceHigh"])) {
$sql .= " AND p.price >='". $data["PriceLow"] ." ' AND p.price <='". $data["PriceHigh"] ."'" ;
}
It returns empty products, meaning the page navigation is available with products missing between. So page one can have 3 products, 2 five products, 4 no products and 5 two products