Magento 1.9 – Get Min and Max Price with Special Price in Product

catalogconfigurable-productproduct

We need min. and max. price from specific category products,

we have tried this query,

$productColl_1 = Mage::getModel('catalog/product')->getCollection()
                        ->addCategoryFilter($categoryModel)
                        ->addAttributeToSort('final_price', 'desc')
                        ->setPageSize(1)
                        ->load();
         echo $max_price = $productColl_1->getFirstItem()->getPrice();

Issue is in this its giving only base on base price but not considering special price for getting minimum price.

Best Answer

Try this:

<?php
  $productColl_1 = Mage::getModel('catalog/product')->getCollection()
    ->addCategoryFilter($categoryModel)
    ->addAttributeToSort('price', 'desc')
    ->setPageSize(1)
    ->load();

    echo $maxPrice = $productColl_1->getFirstItem()->getPrice();
    echo $minPrice = $productColl_1->getFirstItem()->getMinimalPrice();
         //OR
    echo $minPrice = $productColl_1->getFirstItem()->getSpecialPrice();
?>