我正在尝试在标题auto suggest
,
search
结果
form.mini.phtml
<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
<select id="select-category" title="Select your category" name="cat">
<option value="0" selected>Select category</option>
<?php
foreach ($categoryCollection as $category) { ?>
<option value="<?php echo $category->getId(); ?>"><?php echo $category->getName(); ?></option>
<?php } ?>
</select>
<div class="input-box">
<label for="search"><?php echo $this->__('Search:') ?></label>
<input id="search" type="search" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="input-text required-entry" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" placeholder="<?php echo $this->__('Search entire store here...') ?>" />
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button search-button"><span><span><?php echo $this->__('Search') ?></span></span></button>
</div>
<div id="search_autocomplete" class="search-autocomplete"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', '');
searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
</form>
在此表单中,当我输入输入框时,ajax请求会像
一样传递http://127.0.0.1/site/catalogsearch/ajax/suggest/?q=bla
但选定的cat
值未包含在此网址中,如何在Cat="bla"
网址中加入ajax/suggest
http://127.0.0.1/site/catalogsearch/ajax/suggest/?q=bla&cat=bla
谢谢!
答案 0 :(得分:0)
如果您已在任何类别页面上实施此搜索功能,则可以从控制器中获取类别ID以进行过滤:
Mage::registry('current_category')->getId();
如果您仍希望编辑除类别页面以外的页面的ajax调用,可以在以下位置编辑它:
magento / js / varien / js.js(debug initAutocomplete function)