Magento – layered navigation filters

layered-navigation

Is there any way to get the url to only load one filter

Let me brief a bit.I am talking about one filter say size

I have modified the filters to select multiple items at a time

But if a user has selected 3 out of 6 filters. and now the user wants to select only 4 th filter. when user clicks on the that link across the 4 th filter all the other 3 active filters should clear and select only 4 th filter.

$_item->getUrl();
$_item->getRemoveUrl();

But all these urls will have the active filters in them. Is there any magento method for this?

Or should i do little tweeking??

I used $_item->getValueString() to get the values, but it always return the current active plus the filter.Since the price bucket already have , i am not able to use that as delimiter while exploding. Anybody know how to change the , to some any other character in method $_item->getValueString()

Best Answer

So you want to remove all filters from your URL. The block that does that is Mage_Catalog_Block_Layer_State with the method

public function getClearUrl()
{
    $filterState = array();
    foreach ($this->getActiveFilters() as $item) {
        $filterState[$item->getFilter()->getRequestVar()] = $item->getFilter()->getCleanValue();
    }
    $params['_current']     = true;
    $params['_use_rewrite'] = true;
    $params['_query']       = $filterState;
    $params['_escape']      = true;
    return Mage::getUrl('*/*/*', $params);
}

which in turn uses

public function getActiveFilters()
{
    $filters = $this->getLayer()->getState()->getFilters();
    if (!is_array($filters)) {
        $filters = array();
    }
    return $filters;
}

So it iterates over all set filters and unsets them in the query. You could do it exactly like this also from the filter block. Or you can try to access the state block and call the getCleanUrl() method.

Related Topic