Get Minimum and Maximum price of current category from product collection

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 grok 21st October 2026

Thanks for sharing this useful coding solution! Clear examples and practical explanations make it easier for developers to understand and apply new techniques. For readers interested in social media apps and Instagram-related features, InstaPro APK may be worth exploring. Thanks for sharing this helpful resource!

profile grok 21st October 2026

Thanks for sharing this solution for finding the minimum and maximum prices of products in a collection. Clear examples make it easier for developers to understand and apply useful coding techniques. For readers interested in Android apps and cloud storage guides, TeraBox Mod APK may also be worth exploring. Thanks for sharing this helpful resource!

profile grok 21st October 2026

Thanks for sharing this solution for finding the minimum and maximum prices of products in a collection. Clear examples make it easier for developers to understand and apply useful coding techniques. For readers interested in Android apps and cloud storage guides, https://teraboxapkplus.com/">TeraBox Mod APK may also be worth exploring. Thanks for sharing this helpful resource!

profile Ahmad 7th October 2026

O Delta Executor é um executor de scripts Roblox gratuito que injeta scripts Lua personalizados diretamente nos jogos do Roblox. É o executor mais baixado do gênero, com mais de 2,1 bilhões de downloads totais e uma comunidade de 2,5 milhões de membros no Discord.

profile Olivia 16th September 2026

I found the discussion about Magento price filters useful. For readers interested in streaming apps and entertainment, YouCine APK may also be worth exploring 

profile Ahmad 14th August 2026

capcut pro apk download is a modified version of the original CapCut video editor, where premium features are unlocked without any subscription.

profile Ahmad 11th August 2026

GTA San Andreas Mod APK is a modified version of the original Grand Theft Auto: San Andreas mobile game developed by Rockstar Games. While the official version on Google Play Store requires a paid purchase and limits certain game-play elements, this modded APK unlocks everything from the start, giving you access to unlimited money, all weapons, every vehicle, and a powerful CLEO mod menu without spending a single penny.

profile Dorothy 10th August 2026

NetMirror App is a convenient entertainment platform designed for users who enjoy exploring movies, TV shows, and other digital content on Android devices. Its straightforward layout makes browsing easier, while different content categories help users quickly find something interesting to watch. Before installing the app, users should check the source, device compatibility, and required permissions to ensure a safer experience.

profile Jake 10th August 2026

This post effectively highlights how to extract price ranges from product collections. I'd love to hear more about potential implications for e-commerce strategies and customer decision-making! Freecell Solitaire

profile Jeremy 1st July 2026

YouCine APK is a feature-rich streaming application that lets users watch movies, TV shows, live channels, and other entertainment content on Android devices. With an easy-to-use interface, reliable performance, and regular updates, it provides a smooth viewing experience. Install YouCine APK to enjoy entertainment anytime and anywhere.

profile Jeremy 1st July 2026

Grand Theft Auto 6 offers an expansive open world, engaging missions, detailed environments, and immersive gameplay that builds on the series' legacy. Players can explore vibrant locations, interact with dynamic characters, and experience action-packed adventures. GTA 6 promises exciting challenges, improved graphics, and countless hours of entertainment for fans.

profile Jeremy 1st July 2026

Alooy TV APK is a versatile entertainment app that provides access to movies, TV series, live television, and sports content in one place. With fast streaming, an intuitive interface, and frequent updates, it delivers a smooth viewing experience. Download Alooy TV APK to enjoy entertainment whenever and wherever you like.

profile The YT 25th June 2026

A simple way is to loop through the products in the current collection, compare their prices, and store the lowest and highest values. This works well for dynamic price filters, especially if you use the correct variant price. I also share Android and YouTube Premium APK guides that may be useful if you're into app-related content.

profile 5th June 2026

Nutritional support and a holistic approach can be real game-changers for anyone looking to reclaim their health and focus. Managing stress, which often fuels problematic drinking, requires stability across all areas of life, including financial peace of mind

profile 5th June 2026

Nutritional support and a holistic approach can be real game-changers for anyone looking to reclaim their health and focus. Managing stress, https://calcolostipendiosnetto.it.com/  which often fuels problematic drinking, requires stability across all areas of life, including financial peace of mind