Get Minimum and Maximum price of current category from product collection

<?php

namespace Letsknowit\Priceslider\Block;

use Magento\Catalog\Model\Layer\Filter\Price;
use Magento\Catalog\Model\Layer\Filter\FilterInterface;
use Magento\Framework\View\Element\Template;
use Magento\LayeredNavigation\Block\Navigation\FilterRendererInterface;

class FilterRenderer extends \Magento\LayeredNavigation\Block\Navigation\FilterRenderer {
    
    protected $registry;

    protected $request;

    protected $productCollection;

    protected $scopeConfig;

    public function __construct(
        \Magento\Framework\Registry $registry,
        \Magento\Framework\App\RequestInterface $request,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
        \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection,
         \Magento\Backend\Block\Template\Context $context,        
        array $data = [ ]
    ) {
       $this->registry = $registry; 
       $this->request = $request;
       $this->scopeConfig = $scopeConfig;
       $this->productCollection = $productCollection;       
       parent::__construct($context, $data);

    }

    public function getPriceRange($filter) {
          
       $category = $this->registry->registry('current_category');

       $ProductFactory = $this->productCollection->addAttributeToSelect('price')->setOrder('price', 'DESC')->addCategoryFilter($category); 

        $maxPrice = $ProductFactory->getMaxPrice();
        $minPrice = $ProductFactory->getMinPrice();       
        $filterprice = array('min' => $minPrice, 'max' => $maxPrice);
       
        return $filterprice;
    }

?>
 

0   0
Sangita Singh
profile jack 28th April 2026

The age calculator tool provides quick and accurate results, making it easy to track your exact age and plan ahead while staying motivated to achieve your goals like you win rewards in life.

profile William 28th April 2026

Spin Harta APK offers exciting gameplay, smooth graphics, and fun reward features that help players enjoy entertaining spin games and win rewards in less time.

profile Faheem 25th April 2026

on stream mac is searched by viewers looking for a trusted streaming platform that works well on Mac systems.
 

profile Faheem 25th April 2026

onstream app for smart tv is ideal for viewers who prefer movies and TV shows on a larger screen with smooth navigation.
 

profile Faheem 25th April 2026

cricfy tv is searched by viewers who want nonstop sports action, reliable servers, and exciting live match coverage anytime.
 

profile Faheem 25th April 2026

castle tv cast is ideal for users who want to stream favorite movies and shows from mobile devices directly to bigger screens.
 

profile Faheem 25th April 2026

movie box apk offers users a simple way to enjoy premium entertainment, popular films, and series through a user-friendly mobile platform.
 

profile Faheem 25th April 2026

you cine app for android is designed for Android users who want smooth streaming, easy navigation, and quality entertainment options daily.
 

profile Faheem 25th April 2026

geometry dash latest version comes with smoother performance, updated features, and exciting content for players who enjoy precision-based gameplay challenges.
 

profile Faheem 25th April 2026

capcut mod apk provides extra editing tools, creative templates, and stylish transitions that help users make attractive short videos in less time.
 

profile Faheem 25th April 2026

sportzx tv apk allows users to stream multiple sports channels, enjoy live events, and watch trending tournaments with excellent video quality and responsive controls.
 

profile Youcine 9th April 2026

YouCine APK is a downloadable installation file that allows users to access the app outside of official app stores. It provides a convenient way to install the platform on Android devices and enjoy a wide range of movies, series, and live TV content. Known for its fast performance and simple setup, YouCine APK is a popular choice for users who want a flexible and easy streaming experience.

profile AVa 26th March 2026

If you want to design any type of image for your websites then you can easily edit or create images using thepaint3ds.com

profile AVa 26th March 2026

If you want to design any type of image for your websites then you can easily edit or create images using <a href="https:///thepaint3ds.com>thepaint3ds.com</a>

profile Amelia 23rd March 2026

If you’re frequently working with long content like this, especially while following tutorials or guides, it’s often easier to manage your workflow using tools that reduce distractions.

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site