开发者

How do I place a magento autocomplete mini search box outside the magento installation?

开发者 https://www.devze.com 2023-01-10 22:00 出处:网络
I would like to put a magento mini search box in my main website, so that when a search is made, it redirects to the magento search results page. This global search is in the header and helps to find

I would like to put a magento mini search box in my main website, so that when a search is made, it redirects to the magento search results page. This global search is in the header and helps to find products fast on my Codeigniter main site. I was able to achieve part of this, by placing the following code:

<form method="get" action="http://pathtomagento/catalogsearch/result/" id="search_mini_form">
<div class="form-search">
    <label for="search">Buscar:</label>
    <input type="text" class="input-text" value="" name="q" id="search" autocomplete="off">
    <button class="button" title="Buscar" type="submit"><span><span>Buscar</span></span></button>
    <div class="search-autocomplete" id="search_autocomplete" style="display: none;"></div>
    <script type="text/javascript">
        //<![CDATA[
        var searchForm = new Varien.searchForm('search_开发者_开发百科mini_form', 'search', 'Buscar en el catálogo...');
        searchForm.initAutocomplete('http://pathtomagento/catalogsearch/ajax/suggest/', 'search_autocomplete');
       //]]>
    </script>
</div>

The autocomplete function of the search box doesn't work, which is a main issue for me since it's a really useful feature. My main website is full of jQuery, and I know Magento uses prototype. So I managed to include the following scripts that seem to be required by the autocomplete Magento search box:

<script type="text/javascript" src="pathtomagento/js/prototype/prototype.js"></script>
<script type="text/javascript" src="pathtomagento/js/varien/js.js"></script>

Still no luck! I don't get any Console errors in Firebug, but I don't get any AJAX or autocomplete response either. Does anyone know what I could be missing?


Your magento installation has to be on the same server because you can't make crossdomain AJAX requests. Maybe that is the problem in your case?

0

精彩评论

暂无评论...
验证码 换一张
取 消