2013-07-25 56 views
0

当我们在magento网站中搜索一个错误的关键字如“sdfsdf”时,它显示“您的搜索没有返回结果”。在这里,我想显示任何类别的产品,如“类似产品”类别,因为我们在主页上显示“畅销品”。我曾尝试通过调用catalogsearch.xml中的块。 BUt catalogsearch.xml doent包含没有结果的任何块。那么如何在没有结果页面上显示任何类别的产品。在没有结果搜索页面上显示特定类别的产品

我有一个想法,我们可以在.phtml页面上显示特定类别的产品吗?如果我们可以显示特定类别的产品,那么我们可以从“result.phtml”中调用该类别。任何帮助?

我result.phtml

<?php if($this->getResultCount()): ?> 
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?> 
<div class="page-title category-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 category-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> 
<div class="search-noresults"> 
<h1>Meanwhile, You may go through our featured categories:</h1> 
</div> 
<?php echo $this->getLayout()->CreateBlock('catalog/product_list')->setCategoryId(18)->setTemplate('catalog/product/list.phtml')->toHtml();?> 

<?php endif; ?> 

回答

1

一个简单的解决方案是catalogsearch/result.phtml模板内,你将需要设置时,有没有结果

<?php if($this->getResultCount()): ?> 
SHOW RESULTS 
LEAVE DEFAULT 
<?php else: ?> 
NO RESULTS 
<?php echo $this->getLayout()->createBlock('catalog/product_list')->setCategoryId(4)->setTemplate('catalog/product/list.phtml')->toHtml() ?> 
<?php endif; ?> 
+0

感谢乌拉圭回合的答复会发生什么,但按照您的建议添加后,它再次显示没有符合您选择的产品。我认为它也在搜索该类别中的关键字。我已经上传了我的结果.phtml就是上面的问题。建议我。 –

+0

你有没有在system.log或exception.log – elfling

+0

没有nothing.It没有记录任何关于这一点。 –

相关问题