1

First of all, I have been trying to get a better search engine for Magento without adding a plugin.

After changing some query options I have got more or less the result for a search I was looking for. And now I have seen there is a little bug on the category side. At the left side of the products shown. If the product I have searched get 5 products, 2 for textile and 3 for technology, for example, I see on the category menu:

Textile(2)
Technology(3)

So this is right, the results are correct, the problem is when I click on it, it is supposed I should get the 2 textile products when click on it, but this is not happening, it shows me the whole textile products from my database.

When not doing a search on the website and I do only navigate on my products it works perfect. There is something interesting and it is that after doing a search the link changes to: /catalogsearch/result/?q=whateverilookedfor and after clicking on textile I get: /textile.html?q=whateverilookedfor so the search is saved but not showing up.

Do anyone know if there is an option to activate the filter search when click there or something?

0

I found a way to solve it so I post it just in case someone needs it in the future.
I'm not quite sure if this happened because I changed something on my code someday or it's because of Magento's default features.
What I saw is that when clicking on the category link it redirected to the whole items from that category so I changed the href when having done a search. The file I've modified is:

/app/design/frontend/default/yourtheme/template/catalog/layer/filter.phtml

And I removed the whole code:

    <ol>
    <?php foreach ($this->getItems() as $_item): ?>
        <li>
            <?php if ($_item->getCount() > 0): ?>
            <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            (<?php echo $_item->getCount() ?>)
        </li>
    <?php endforeach ?>
    </ol>

for this one.

    <ol>
    <?php foreach ($this->getItems() as $_item): ?>
        <li>
            <?php if (($_item->getCount() > 0) && (strpos($_SERVER['REQUEST_URI'],'catalogsearch') === false)): ?>
            <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
            <?php 

            elseif(strpos($_SERVER['REQUEST_URI'],'catalogsearch') == true): //afegitó 
                $category = Mage::getResourceModel('catalog/category_collection')->addFieldToFilter('name', $_item->getLabel());
                $cat_det=$category->getData();
                $category_id=$cat_det[0][entity_id];

            ?>
            <a href="<?php echo $_SERVER['REQUEST_URI']?>&cat=<?php echo $category_id ?>"><?php echo $_item->getLabel() //afegitó ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            (<?php echo $_item->getCount() ?>)
        </li>
    <?php endforeach ?>
    </ol>

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.