Question

This is the block from my catalogsearch.xml

<reference name="left">
        <block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
    </reference>

The selected filters are displaying multiple time.I tried changing the type and still no change, Please Help. enter image description here

update :

in my catalog\layer\state.phtml

$_filters = $this->getActiveFilters();
count($_filters) 

is returning me 3 which should be only one .Please help why this is happening

Was it helpful?

Solution

check the xml for duplicate catalogsearch.leftnav block

OTHER TIPS

You'll need to loop over the $_filter results most likely just like the RWD theme does in state.phtml

$_filters = $this->getActiveFilters();
$_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChildren();
?>
<?php if(!empty($_filters)): ?>
<div class="currently">
    <p class="block-subtitle"><?php echo $this->__('Currently Shopping by:') ?></p>
    <ol>
    <?php foreach ($_filters as $_filter): ?>
        <?php
        $_rendered = false;
        foreach ($_renderers as $_rendererName):
            $_renderer = $this->getParentBlock()->getChild('state_renderers')->getChild($_rendererName);
            if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_filter)):
                $_renderer->setFilter($_filter);
                echo $_renderer->toHtml();
                $_rendered = true;
                break;
            endif;
        endforeach;

...

Also, every filter renderer is where the list of states are collected, and also notice the use of getItemsCount instead of native PHP count, avoid using count on the ORM/Collections as they have big performance impacts:

protected function _initFilter()
{
    if (!$this->_filterModelName) {
        Mage::throwException(Mage::helper('catalog')->__('Filter model name must be declared.'));
    }
    $this->_filter = Mage::getModel($this->_filterModelName)
        ->setLayer($this->getLayer());
    $this->_prepareFilter();

Related:

You need to edit the file mentioned below, in the current theme /app/design/frontend/PACKAGE/THEME/template/catalog/layer/state.phtml

This is the actual code:

$_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChildren();

Replace by:

$_renderers = $this->getParentBlock()->getChild('state_renderers');

layout-catalogsearch.xml Comment out a part of the code, clean the cache.

<catalogsearch_result_index translate="label">
    <label>Quick Search Form</label>
    <reference name="root">
        <action method="setTemplate"><template>page/3columns.phtml</template></action>
    </reference>
    <!--<reference name="left">-->
        <!--<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml">-->
            <!--<block type="core/text_list" name="catalog.leftnav.state.renderers" as="state_renderers" />-->
        <!--</block>-->
    <!--</reference>-->
    <reference name="content">
        `enter code here`
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top