On my site i have an input textbox where you can enter some searchtext. The results of this search should show up in a dropdown below the textbox (autocomplete like).

When i hit enter in the textbox Magento searches like this:


I want the dropdown results to be the same as what Magento gives back with the above searchmethod.

I tried with following code:

        $_query = Mage::helper('catalogsearch')->getQuery();

        $_productCollection = Mage::getModel('catalogsearch/fulltext')->getCollection()

The problem here is that it only works on searchcriteria that has already been processed by the first method (by hitting enter in the textbox).

Can anyone point me out how Magento manages this search? I know that the ResultController handles this method in a way, but i can't figure it out.

Thank you in advance.

UPDATE: Turns out to be that the query needed to be prepared first

        $_query = Mage::helper('catalogsearch')->getQuery()

        $_productCollection = Mage::getResourceModel('catalogsearch/fulltext_collection')

1 Answer 1

$queryText = Mage::helper('catalogSearch')->getQueryText();

$collection = Mage::getResourceModel('catalogsearch/query_collection')

May this helps

  • I updated the question with the solution that worked for me. Appreciate your answer, thanks.
    – excaliber
    Sep 25, 2013 at 15:26

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.