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 less chances to guess the dirty ones). For the explained below, I don't expect you hit in the nail about, but give me some guidance about.

Let's see...

When I send a standard search query to /index.php/catalogsearch/result/?q=, I find products not present in many "states". By "states" I mean possible discrete values of "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 setup 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 a 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 :( – Luis Masuelli Mar 31 '14 at 14:11

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

method prepareProductCollection

magento select 'clear collection (method getProductCollection) and then apply catalogsearch 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

| improve this answer | |

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.