i'm using layered navigation in product view page.

On click on any filter, it's simply appending those filter at the end of current url


This is my current product page url,


On same product page if i filter by price, i'm redirecing to


I should go to category listing page,


getUrl() is the function which is generating url from /app/code/core/Mage/Catalog/Model/Layer/Filter/Item.php

It's mentioned like below,

public function getUrl()
        $query = array(
            Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null // exclude current page from urls
        return Mage::getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));

Above function simply appending filter at the end of current url. This works fine in category page but not in product page.

Is there any way to make it work in product page by altering url ?

  • 2
    Why would you need the layered nav in the product view page? It is not supposed to work like that.
    – Marius
    Jul 30, 2014 at 7:08
  • @Marius yes I know Buddy. But my client badly needs it. He wish to give flexibility to end users who can able to filter products even they are in product page too. Jul 30, 2014 at 7:18
  • So why you don't want to rewrite this method and determine current category instead of using just current url?
    – Amasty
    Jul 30, 2014 at 21:19

1 Answer 1


The question already contains half of the answer.

Rewrite the mentioned class app/code/core/Mage/Catalog/Model/Layer/Filter/Item.php and determine if we at the product page. For example like if(Mage::registry('current_product')) then get the first category of the current product and its URL as a base.

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