我正在搜索产品,但它正在展示另一类产品。我认为我的搜索页面在magento中无法正常工作。我无法找到错误。
如果有人知道这一点,请帮助我。
谢谢!
我在template/catalogsearch/result.phtml
中添加了此代码,该代码位于
<?php if($this->getResultCount()): ?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="page-title">
<?php if ($this->helper('rss/catalog')->getTagFeedUrl()): ?>
<a href="<?php echo $this->helper('rss/catalog')->getTagFeedUrl() ?>" class="nobr link-rss"><?php echo $this->__('Subscribe to Feed') ?></a>
<?php endif; ?>
<h1><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>
</div>
<?php if ($messages = $this->getNoteMessages()):?>
<p class="note-msg">
<?php foreach ($messages as $message):?>
<?php echo $message?><br />
<?php endforeach;?>
</p>
<?php endif; ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<div class="page-title">
<h1><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>
</div>
<p class="note-msg">
<?php echo ($this->getNoResultText()) ? $this->getNoResultText() : $this->__('Your search returns no results.') ?>
<?php if ($messages = $this->getNoteMessages()):?>
<?php foreach ($messages as $message):?>
<br /><?php echo $message?>
<?php endforeach;?>
<?php endif; ?>
</p>
<?php endif; ?>
<?php
$searchTerm = $this->helper('catalogSearch')->getEscapedQueryText();
$categories = $this->helper('catalog/category')->getStoreCategories(false, true);
$count = 0;
foreach ($categories as $count_category) {
if ($this->helper('catalog/category')->canShow($count_category) && stripos($count_category->getName(), $searchTerm) !== false)
$count++;
}
if ($count > 0):
echo "<div class=\"search-term-notice\">";
echo "The following product categories matched your search:";
foreach ($categories as $category) {
if ($this->helper('catalog/category')->canShow($category) && stripos($category->getName(), $searchTerm) !== false)
echo "<h3> > <a href='".$category->getUrl()."'>".$category->getName()."</a></h3></p>";
}
echo "</div>";
endif;?>
当我通过提供类别名称进行搜索时,它会显示不同类别的产品,包括搜索到的产品。所以请修改我的代码以便适当的产品来