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;
}
?>
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
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>
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.
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. Some users prefer using a YouTube mod APK to watch tutorials without interruptions like ads or restrictions, which can help when you’re trying to focus on detailed explanations. https://ytmodz.com/
Kindly balanced in difficulty and flow, Slope Game 2 offers a welcoming arcade experience that helps players feel comfortable while improving control, as smooth physics and fair pacing encourage confidence, patience, and steady skill growth through repeated and enjoyable play sessions over time.
Suman
7th March 2026
The rising demand for Delhi call girls is a reflection of the importance that people attach to companionship in the midst of a busy city.
Chanakyapuri Escorts Service || Escorts Service Greater Kailash || Escorts Service in Saket || Karol Bagh Escorts || Escorts in Rohini ||
Mubashar
3rd March 2026
Knowing the minimum and maximum prices in a product category helps customers make informed choices and saves time while browsing. It’s especially useful for exploring a menu or collection, where options can vary widely in flavor, size, or specialty. Clear price ranges give users confidence and improve the overall experience, making it easier to find exactly what they want. https://besturdunovel.com/
Mubashar
3rd March 2026
Getting the minimum and maximum price of the current category from a product collection is a smart way to improve filtering and enhance the user experience. It helps visitors quickly understand the price range and make better purchasing decisions without scrolling endlessly. Clear pricing insights not only build trust but also make navigation smoother and more efficient. Organizing and presenting information properly always adds value for users exploring different options.https://7brewwmenu.com/
thomas
5th February 2026
You can loop through the products in the selected collection, collect their price values, and then apply a min and max calculation before displaying the result. This method keeps the price range accurate even when items are added, removed, or updated. It works especially well for categories with frequently changing prices or limited-time items. https://thepandaexpressmenu.com/
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/
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/
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
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/
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.
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/
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