How to change the price range in layered navigation in Magento? - See more at: http://www.expertweba

Magento layered navigation is the great functionality and you can include any product attributes through the admin and the price range is the default layered functionality which is already included by the Magento. But it has own price range but in this post I am trying to describe how to change the price range in layered navigation in Magento. Here are the steps given below:

Step 1. Just navigate to the /app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php
Step 2. 
Open the file in your favorite editor and search for the getPriceRange() function and replace the code from the below code.

public function getPriceRange()
    {
        $range = $this->getData('price_range');
        if (is_null($range)) {
            $maxPrice = $this->getMaxPriceInt();
            $minPrice = $this->getMinPriceInt();
            $index = 1;
            do {
                $range = pow(10, (strlen(floor($maxPrice))-$index));
                $items = $this->getRangeItemCounts($range);
                $index++;
            }
            while($range>self::MIN_RANGE_POWER && count($items)<5);
            
            if((($range*5)>self::MIN_RANGE_POWER)&& (count($this->getRangeItemCounts($range*5))>5))
                $range = $range*5;
            if((($range*2)>self::MIN_RANGE_POWER)&& (count($this->getRangeItemCounts($range*2))>5))
                $range = $range*2;

            $this->setData('price_range', $range);
        }
        return $range;
    } 

Note : Please do not edit the core Magento code file you can put this file into the /app/code/local/Mage/Catalog/Model/Layer/Filter/Price.php and put the Magento core code file as it is.

Hope it helps, Thanks and enjoy the reading.

- See more at: http://www.expertwebadvisor.com/how-to-change-the-price-range-in-layered-navigation-in-magento/#sthash.WgrnG6kd.dpuf


source: http://www.expertwebadvisor.com/how-to-change-the-price-range-in-layered-navigation-in-magento/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值