Magento - Offer auto-complete not working

I included a new theme in Magento v1.4.2.0 and made all the necessary changes, but only after the true Magento method for redefining Magento modules and methods.

My only problem is that the auto-complete function assumes that the search function in the interface does not work at all. AJAX works because I can view calls in " Firebug " (with the status displayed as "200 OK"), but the drop-down box for search results is not suitable.

Additional Information:

  • Checks the form method and is set as " get ".
  • The name of the text field in " form.mini.phtml " is " q ".
  • Check the log files ( exception.log and system.log ), but nothing is printed here regarding the automatic completion of the search.
  • Check the settings for the minimum request length (from " System> Configuration> Directory> Directory Search> Minimum Request Length "), and it is set to " 1 ".
  • Include all the HTML on the page " form.mini.phtml " as accurately as possible, including all the necessary JS files without any errors in them. As a result, Firebug reports AJAX blank / NULL responses without any errors.

Edit: -
I am also having another problem. Let's say I have 4 products, each of which starts with the name " Test ". Also suppose that the name of these 4 products is " Test 1 ", " Test 2 ", " Test 3 ", " Test 4 ".
Now, if I do a simple search with the query " Test " in the router " catalogsearch/index ", the result shows that there are 4 products available, which is correct. But if I do a search with a query like " Test 1 ", then the results are not displayed, which is very strange.

I also use " jQuery ", without conflict conditions. However, there are also 6 " jQuery " plugins, all of which perfectly do not meet the condition of no conflict. This is because the code in some of these plugins is huge, and I cannot change every $ sign to jQuery , which makes it non-conflicting. Can anyone suggest for this kind of problem? And does this affect the automatic search suggestion?

+7
source share
4 answers

It sounds like there is a problem with the way the server responds to AJAX calls, and not a problem with the form or javascript. I would suggest that you need to debug a couple of key areas.

Ideally, you will debug this using Xdebug on your Apache connected to your IDE (Netbeans, Eclipse, etc.). My personal preferences / settings are Netbeans, but others will work fine. If you cannot use live debugging, you can embed print_r / echo instructions through code blocks and track the call this way.

  • Mage_CatalogSearch_AjaxController

javascript on form.mini.phtml should send a request to Mage_CatalogSearch_AjaxController and suggestAction . Set breakpoints / trace messages on each side of the first if in this method.

If the breakpoint / trace does not fall, try to manually perform the action by placing http://hostname/catalogsearch/ajax/suggest?q=query in the address bar of the browser.

If this does not work, there is something broken with the configuration of the catalogsearch module, possibly with the section <frontname><routers> . Use the Alan Storm Configviewer or CommerceBug modules to debug them.

  1. Mage_CatalogSearch_Block_Autocomplete

AjaxController creates an instance of Mage_CatalogSearch_Block_Autocomplete that executes the actual request. Set a breakpoint / trace immediately before $suggestData = $this->getSuggestData(); to verify that the block is receiving an instance.

After this line, the block calls its own getSuggestData() method. Keep track of the code to see where the error occurred.

  1. Mage_CatalogSearch_Model_Query :: getSuggestCollection ()

The block calls this method to obtain values ​​that correspond to the q parameter, in particular, the setQueryFilter() method, which inserts this parameter into the SQL query criteria. Again, follow here to find the error.

I can't really emphasize how much easier it will be for you to find this (and most Magento issues) when you use live debugging in your IDE. Read my answer here if you need advice on this process.

Make sure you have a Developer Mode server to display as many errors as possible.

+6
source

If you are viewing the source of the working site (view-source: http://demo.magentocommerce.com/), you should find that the search form looks like this:

 <div class="form-search"> <label for="search">Search:</label> <input id="search" type="text" name="q" value="" class="input-text" /> <button type="submit" title="Search" class="button"><span><span>Search</span></span></button> <div id="search_autocomplete" class="search-autocomplete"></div> <script type="text/javascript"> //<![CDATA[ var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Search entire store here...'); searchForm.initAutocomplete('http://demo.magentocommerce.com/catalogsearch/ajax/suggest/', 'search_autocomplete'); //]]> </script> </div> 

The important part is an element named search_autocomplete , and its identifier is passed to searchForm.initAutocomplete() . Also make sure your new theme includes prototype.js and files from js/varien/ and does not have any other Javascript errors.

+3
source

Please check once what you are looking for after the word, do you know that the product exists. If it cannot be displayed, press "Enter" and you will be sent to view the results. After this test, if now you can find the article in the proposed search.

+3
source

I have the same problem ... it looks like there is a search error or conflict with some mabye extension in German markets ...

Check what you get if you enter this: http://www.studio-ausruestung.de/catalogsearch/ajax/suggest/?q=% with your file name, of course.

Normal, you should get all the results ...

+3
source

All Articles