如何在 magento 安装之外放置 magento 自动完成迷你搜索框?

发布于 2024-09-13 05:43:42 字数 1422 浏览 2 评论 0原文

我想在我的主网站中放置一个 magento 迷你搜索框,以便在进行搜索时,它会重定向到 magento 搜索结果页面。此全局搜索位于标题中,有助于在我的 Codeigniter 主站点上快速查找产品。通过放置以下代码,我能够实现部分目的:

<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>

搜索框的自动完成功能不起作用,这对我来说是一个主要问题,因为它是一个非常有用的功能。我的主网站充满了 jQuery,而且我知道 Magento 使用原型。所以我设法包含了自动完成 Magento 搜索框似乎需要的以下脚本:

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

仍然没有运气!我在 Firebug 中没有收到任何控制台错误,但也没有收到任何 AJAX 或自动完成响应。有谁知道我可能会错过什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海螺姑娘 2024-09-20 05:43:42

您的 magento 安装必须位于同一台服务器上,因为您无法发出跨域 AJAX 请求。也许这就是你的情况的问题?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文