Skip to main content
4 of 4
improved formating
Qaisar Satti
  • 32.5k
  • 18
  • 87
  • 137

Magento 2, get Min and Max price in Layered Navigation

I am trying to get Min & Max price in Layered Navigation and I am using a third party extension for layered navigation..

By using below script, I am trying to get Min & Max price for filter collection.

  public function getPriceRange($filter){
     $Filterprice = array('min' => 0 , 'max'=>100);
    if($filter instanceof Magento\CatalogSearch\Model\Layer\Filter\Price) {
        $priceArr = $filter->getResource()->loadPrices(10000000000);           
        $Filterprice['min'] = reset($priceArr);
        $Filterprice['max'] = end($priceArr);
    }

    return $Filterprice;
}

But it says loadprice not a method. Can any please suggest to get Min & Max price.

Ramesh
  • 986
  • 1
  • 14
  • 40