Beforehand I have to tell: I'm a total n00b on Magento and what I need to know is more a "common practice" or "standard" about how is something achieved in Magento since I have to maintain (in record time) a Magento distribution (perhaps the previous developers created a dirty way to do what I will ask, but if I don't know the standard ways, I'll have even fewer chances to guess the dirty ones). For the explanation below, I don't expect you to hit the nail about it, but give me some guidance about it.

Let's see...

When I send a standard search query to /index.php/catalog search/result/?q=, I find products not present in many "states". By "states" I mean possible discrete values of the "Estado" attribute (a custom attribute for my Products).

As I can see, Products having certain values for "Estado" are not shown in the results (even when Visibility is set to include those products in the search results).

Question: Is there a place where I can set up a custom filter to use for my product list (as obtained from the search query) so I can keep only products in a certain state? What does Magento support, as standard, regarding that?

For "place" I mean an option in the Admin backend or, as the very last option, a chunk of code, event, callback, hook, interceptor, middleware, or whatever (I'm an n00b so I don't know the true term used in Magento) is used in these cases to intercept the query.

Notes: In app/design/frontend/caramel/template/catalog/product/list.phtml the first lines before iteration are:

    $_helper = $this->helper('catalog/output');
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<p>No encontraste lo que buscabas, <a href="<?php $_SERVER['HTTP_HOST']?>/index.php/pidenos?tipo=pidenos">p&iacute;denos</a> y lo buscamos por ti.</p>
<?php else: ?>
<!-- more code here ... -->

And as I can see, the filter is not applied here but it comes from somewhere else, and I want to know where does it come from (usually).

  • 1
    Another tumbleweed for me :( Mar 31, 2014 at 14:11

1 Answer 1


at this file Magento output result collection with all filters, sorting, pagination, etc.

method prepareProductCollection

Magento selects 'clear collection (method get product collection) and then applies catalog search filter (where condition) for this collection and route collection to layered navigation.

you can use <?php echo $_productCollection->getSelect() ?> in template for output current sql query to database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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