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 Grace 27th May 2025

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

Write a comment ...
Post comment
Cancel
profile 4th May 2025

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

Write a comment ...
Post comment
Cancel
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

Write a comment ...
Post comment
Cancel
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

Write a comment ...
Post comment
Cancel
profile vu 6th March 2025

Lo Top - Live commentary of today's 3-region lottery quickly and accurately. Lo Top Dragon Platinum 3-region live daily. lo top

Write a comment ...
Post comment
Cancel
profile Nguyen 1st January 2025

Bạn đã biết cách tham gia và tăng cơ hội trúng thưởng chưa? Cùng Dự đoán Xổ số Đồng Nai khám phá ngay những bí quyết thú vị! xổ số Đồng Nai

Write a comment ...
Post comment
Cancel
profile Nguyen 14th December 2024

Kết quả trúng thưởng Xổ Số An Giang được xác định bằng cách đem so sánh dãy số trong tờ vé số với kết quả mở thưởng của nhà đài. xổ số an giang

Write a comment ...
Post comment
Cancel
profile Nguyen 14th December 2024

có không ít người vẫn chưa biết cách chơi XSTN. Vậy hãy cùng  Dự đoán xổ số An Giang tìm hiểu cách chơi và kinh nghiệm tăng khả năng trúng thưởng nhé dự đoán xsag

Write a comment ...
Post comment
Cancel
profile Armstrong 11th December 2024

Plumbing Service Group offers fast and reliable emergency plumbing services 24/7. Our experienced plumbers are equipped to handle all urgent issues, from burst pipes and severe leaks to clogged drains and malfunctioning water heaters. We prioritize swift response times and efficient solutions to minimize damage and restore your plumbing system quickly. Trust Plumbing Service Group for professional, dependable emergency plumbing assistance whenever you need it.
 

Write a comment ...
Post comment
Cancel
profile Nguyen 10th October 2024

vin777 is known as one of the leading bookmakers in Asia. The vin777 website will share all the necessary information for those who need it. This is vin777's newest homepage - please click here tải app vin777

Write a comment ...
Post comment
Cancel
profile Nguyen 10th October 2024

789win is known as one of the leading bookmakers in Asia. The 789win website will share all the necessary information for those who need it. This is 789win's newest homepage - please click here Readmore: 789win

Write a comment ...
Post comment
Cancel
profile Arnold 4th October 2024

The writer uses practical, clear examples to explain the subject effectively. The visuals add to the understanding without being distracting, and the engaging tone keeps the reader involved throughout the post. i also like chickfila-menus.com

Write a comment ...
Post comment
Cancel
profile Nguyen 3rd October 2024

J88 is a bookmaker that is making waves in the online gaming community and those who love online betting. J88ld is not simply a bookmaker, but also a miniature entertainment world. With a series of interesting and exciting betting entertainment games. Readmore: j88

Write a comment ...
Post comment
Cancel
profile Nguyen 27th September 2024

33win is a bookmaker that is making waves in the online gaming community and those who love online betting. 333win is not simply a bookmaker, but also a miniature entertainment world. With a series of interesting and exciting betting entertainment games. Readmore: 333win

Write a comment ...
Post comment
Cancel
profile Nguyen 21st September 2024

Kuwin Top reputable online casino in Vietnam⭐️Guaranteed reputation for ten years⭐️Register now, receive generous rewards immediately️ - please click here Readmore: kuwin

Write a comment ...
Post comment
Cancel

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