Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Retrieve highest product price in current collection from layered nav

Tags:

filter

magento

Layered navigation filters are created in

app/design/frontend/base/theme/template/catalog/layer/filter.phtml

How can I retrieve the value of the highest product price in the current product collection from within this file?

I've tried what I thought was the obvious choice $this->getMaxPriceInt() from Mage_Catalog_Model_Layer_Filter_Price but that does not seem to work within filter.phtml.

like image 549
gpcola Avatar asked Dec 07 '25 03:12

gpcola


2 Answers

Assuming $collection is a collection of 'catalog/product', this should do the trick:

$product = $collection->setOrder('price', 'DESC')->getFirstItem();
like image 141
Magento Guy Avatar answered Dec 09 '25 01:12

Magento Guy


Get highest and lowest price in category listing you can use below code.

$min_price = Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMinPrice();
$max_price = Mage::getSingleton('catalog/layer')->setCurrentCategory(Mage::registry('current_category'))->getProductCollection()->getMaxPrice();

But it is not working for search and advance search layer navigation.so you can use below code for all pages layer navigation.

$min_price = $this->getLayer()->getProductCollection()->getMinPrice();
$max_price = $this->getLayer()->getProductCollection()->getMaxPrice();
You can use below code on app/design/frontend/THEME/default/template/catalog/layer/view.phtml file.
like image 43
himansu Avatar answered Dec 09 '25 01:12

himansu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!