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 james 13th December 2025

The key is to narrow the collection to the exact category first, then run min and max calculations on that filtered data. This avoids issues with variants or mixed pricing. I use a similar structured approach when organizing skill-based learning resources, where clear grouping makes ranges easier to manage. You can see a practical example of this kind of organization here: https://www.zahidmuzaffarkhan.com/

profile olivia 13th December 2025

Getting the minimum and maximum price from a product collection is much easier if the data is clean and well-structured. Clear logic and consistent fields make aggregation simple. Similarly, tools that keep workflows straightforward are always effective-for example, this Pinterest video downloader works just by copy-pasting the link: https://pinterestdownloader.com.br/

profile olivia 10th November 2025

the key is to filter the product collection by that category ID before running any price functions. If the collection isn’t filtered first, you’ll end up with global values instead of category-specific ones. In most frameworks, you can apply a category filter, select the price column. https://apkcineema.com.br/

profile olivia 10th November 2025

the key is to filter the product collection by that category ID before running any price functions. If the collection isn’t filtered first, you’ll end up with global values instead of category-specific ones. In most frameworks, you can apply a category filter, select the price column. https://apkcineema.com.br/

profile Archie 9th October 2025

Awami Products offers natural wellness solutions with quality and care. From grounding mats that connect you to Earth’s energy to detox pads and foot masks that refresh and heal, every product reflects comfort, balance, and trust. Perfect for those who value relaxation, health, and genuine results. https://awamiproducts.com/

profile Elsa 6th October 2025

Hi Dear, getting the minimum and maximum product price from the current category collection is a smart way to show dynamic price ranges on your store. It helps customers quickly understand what fits their budget and improves their browsing experience. By the way, if you enjoy learning about apps and digital tools, you might like exploring Kuku TV Mod APK, an awesome entertainment app packed with shows and movies optimized for mobile users. Visit here : https://kukutvapk.com

profile ella 26th September 2025

Looking at the product collection, the minimum price in this category is $16.99 (Awami Foot Detox Pads), while the maximum price is $59.00 (Awami 3-in-1 Detox & Grounding Kit). This shows Awami offers both affordable wellness essentials and premium bundles, giving customers flexible choices. It’s a smart pricing strategy that caters to different budgets while maintaining product variety. https://awamiproducts.com/

profile Nora 26th September 2025

This Magento code nicely gets the min and max price for products in the current category. It feels a bit like using the Car Parking MOD Version VIP Menu, where you also get full access to ranges and features that aren’t normally available, giving more control and flexibility.

profile Nora 25th September 2025

That’s a useful feature for product collections, knowing the min and max price helps shoppers make quick decisions. In the same way, the Updated DQ menu with prices 2025 makes it easier for customers to see all Dairy Queen options clearly, from budget-friendly treats to premium items, so everyone can find something that fits their range.

profile Emaa 11th September 2025

I really appreciated the clarity of your explanation—it made it much easier for me to choose the perfect meal from the <ahref="https://zaxbysmenuprice.com/">Zaxby’s menu</a>.

profile Emaa 11th September 2025

I really appreciated the clarity of your explanation—it made it much easier for me to choose the perfect meal from the .<a href="https://zaxbysmenuprice.com/">Zaxby’s menu</a>

Emaa
11-09-2025 00:00

I really appreciated the clarity of your explanation—it made it much easier for me to choose the perfect meal from the <ahref="https://zaxbysmenuprice.com/">Zaxby’s menu</a>.

Emaa
11-09-2025 00:00

I really appreciated the clarity of your explanation—it made it much easier for me to choose the perfect meal from the <ahref="https://zaxbysmenuprice.com/">Zaxby’s menu</a>.

Emaa
11-09-2025 00:00

I really appreciated the clarity of your explanation—it made it much easier for me to choose the perfect meal from the <ahref="https://zaxbysmenuprice.com/">Zaxby’s menu</a>.

profile Grace 27th May 2025

Really loved the way you explained! it helped me selecting a perfect meal from menu at Zaxbys.

profile 4th May 2025

clear examples to explain the subject effectively chick-fil-a-menus.com

profile Zane 29th April 2025

Welcome to McDonald's in Japan! I tried the unique menu items the make McDonald's in Japan better than America.visit

profile Zane 29th April 2025

McDonald’s Australia blends global classics with local favorites like the Aussie Angus Burger and McCafé drinks, offering something for everyone.Readmore:mcdmenu

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