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 jon 23rd January 2026

For current category min/max price, filter products by category first, then use an aggregate query with $group + $min and $max on the price field. This is fast and perfect for showing a price range filter on category pages in fashion stores. https://apricocia.com/

profile Jack 23rd January 2026

Fetching minimum and maximum prices from a product collection is a smart way to improve category filtering and give users quick pricing context. This approach works especially well for menu-style listings where visitors want to compare options at a glance without opening each item. Clear price ranges make navigation smoother and help users decide faster while browsing structured collections. https://theolivegardenmenu.com/

profile james 23rd January 2026

By calculating min and max prices directly from the active product collection instead of relying on static values. It keeps filters accurate when products or variants change and avoids mismatches on category pages. The same idea applies in other tools that work with dynamic ranges and profiles, like configuration-driven software. A similar concept is explained here: https://orcaslicer.pro

profile Jaxon 19th January 2026

Getting accurate minimum and maximum prices from a product collection really comes down to clean logic and consistent data handling, especially when values keep changing. I’ve used a similar structured approach when tracking totals and ranges with time-based data, and tools like this hours worked calculator explain that mindset well: https://calculadoradehorasgratis.com.br/

profile Nora 13th January 2026

The Updated DQ Menu USA 2026 brings new flavors along with classic favorites fans already love. From Blizzards to burgers and treats, the menu reflects fresh updates and seasonal options. Always check the official menu to get the latest prices and items.

profile X 24th December 2025

When dealing with minimum and maximum price logic in a product collection, it really helps users quickly understand the value range before making a choice. I’ve seen a similar mindset in content platforms, where people compare paid subscriptions versus free alternatives. For example, while exploring media apps, I came across a detailed breakdown of feature access and limits here: https://theytpremium.com/

profile samuel 23rd December 2025

You can simplify this by keeping your category data consistent and letting the query calculate min and max dynamically instead of hard-coding values. I ran into a similar setup while structuring app version details for comparisons, and this approach saved a lot of cleanup later shared a related example here if it help https://mtmanagersapk.com/

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.

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