1

I have a category which uses a custom product collection and layered navigation. Everthing is working fine except the price filter (Magento 1.9). It displays the correct price ranges, but does not filter the products when clicked.

I am also using the Amasty Improved Navigation plugin, so instead of extending the core directly, I extended the plugin's classes which in turn extend the core. Basically I modified the getLayer() function in

Mage_Catalog_Block_Layer_View
Mage_Catalog_Block_Product_List

to use my custom collection and applyFilterToCollection(), _getItemsData() in addition to adding a custom function to get my custom collection in

Mage_Catalog_Model_Layer
Mage_Catalog_Model_Category
Mage_Catalog_Model_Layer_Filter_Attribute

This gets me a working toolbar, pagination and layered navigation except for the price filter - the filters are working correctly for any other attribute. But using the price filter, it returns a page with the correct URL, but in the Product_List Block I get the same, unfiltered products.

Looking into the core, I found the following function which looked promising at first:

Mage_Catalog_Model_Resource_Layer_Filter_Price

applyPriceRange($filter) {
    ...
    $select = $filter->getLayer()->getProductCollection()->getSelect();
    ...
}

However, "injecting" my custom function/collection did not change anything (I tried extending the plugin's classes as well as the core with the plugin disabled). I also looked into _getSelect($filter) in Mage_Catalog_Model_Resource_Layer_Filter_Price but without success.

Where can I hook into to make the price filtering work with my custom collection? How does the Layered Navigation Price Filter work, does use it use its own method to get the product collection?

2 Answers 2

1

Price filter uses a bit different SQL query. It tries to avoid joining with the product entity table and replace it with the price index.

As you are using layered navigation module, you need to modify class app\code\local\Amasty\Shopby\Model\Mysql4\Price.php instead of the magento default.

2
  • The price filter is working without any modification when I disable the Improved Navigation module. In the module it's confusing as there are multiple price files, price13.php, price17.php, price.php, price14ce.php, price17ce.php and so on, extending the core but also other classes of the same module. I guess Amasty_Shopby_Model_Mysql4_Price17 is the correct one as it rewrites Mage_Catalog_Model_Resource_Layer_Filter_Price. I still could not find out where the module is getting the collection or applying the price filter, will continue my research but any help is appreciated =)
    – Socrates
    Commented Oct 12, 2014 at 15:24
  • The module supports many magento version, as the price logic is different. The easiest way just to email to our support I think if simple solutions do not help.
    – Amasty
    Commented Oct 13, 2014 at 10:25
1

if you are using FME "Layered Navigation" extension, please fix the 'default mode' price bug by following way:

app\code\local\FME\Layerednav\Block\List.php

Edit function:

protected function _getProductCollection() {
    if (is_null($this->_productCollection)) {       

        $this->_productCollection = Mage::getSingleton($this->_module . '/layer')
                ->getProductCollection();

        /***
        starts, 
        quick fix for price filter if mode inside admin is set to 'default'
        ***/
        if($_GET['price']) {
            $sOnStatement = "(((price_index.min_price)*1) >= '".$_GET['price']."')";                           
            $this->_productCollection->getSelect()->where($sOnStatement);                   
        }       
        /***
        ends, 
        quick fix for price filter if mode inside admin is set to 'default'
        ***/            
    }

    return $this->_productCollection;
}

Thanks, Kashif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.