2

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()

  • you tweaked already. Magento can't handle multiple values out of the box, so go on your way :) – Fabian Blechschmidt Dec 6 '13 at 17:12
1

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.

  • how will i call getClearLinkUrl from my filter.phtml? – zamil Dec 6 '13 at 19:17
  • getRemoveUrl removes the filter from the url, but i want that filter in url with all others removed.I tried with getValueString but that gives u the active filters also as a sting – zamil Dec 6 '13 at 19:19
  • @zamil I updated my answer to shed some light on how to reset the URL to have no filters set. – mpaepper Dec 6 '13 at 22:45
  • Thanks for your time. But my pbm is not getting the clear url. I already have the clear url in my filter.phtml. I am not able to append the only filter criteria to that clear url when there are already many filters are active.And i am trying to do this in filter.phtml – zamil Dec 7 '13 at 4:36
  • please see my question edit – zamil Dec 7 '13 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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