Magento 在无结果搜索页面上显示特定类别的产品

Magento 在无结果搜索页面上显示特定类别的产品,magento,magento-1.7,magento-1.4,magento-1.5,magento-1.6,Magento,Magento 1.7,Magento 1.4,Magento 1.5,Magento 1.6,当我们在magento站点中搜索错误的关键字(如“sdfsdf”)时,它会显示“您的搜索未返回任何结果”。在这里,我想显示任何类别的产品,如“类似产品”类别,因为我们在主页上显示“畅销书”。我尝试调用catalogsearch.xml中的块。但是catalogsearch.xml不包含任何无结果块。那么我如何在无结果页面上显示任何类别的产品呢 我有一个想法,比如我们可以在.phtml页面上显示特定类别的产品吗?如果我们可以显示特定类别的产品,那么我们可以从“result.phtml”中调用该类别

当我们在magento站点中搜索错误的关键字(如“sdfsdf”)时,它会显示“您的搜索未返回任何结果”。在这里,我想显示任何类别的产品,如“类似产品”类别,因为我们在主页上显示“畅销书”。我尝试调用catalogsearch.xml中的块。但是catalogsearch.xml不包含任何无结果块。那么我如何在无结果页面上显示任何类别的产品呢

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

my 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; ?>


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

显示结果
违约
没有结果

感谢您的回复,但按照您的建议添加后,再次显示没有与您选择的产品匹配的产品。我认为它也在搜索该类别中的关键字。我已经更新了我的结果。phtml是上面的问题。建议我。你在system.log或exception.logOk中有什么。。。因此,我已经做了一些测试,目前无法找到显示类别的解决方案。但我推荐的是安装一个免费的特色产品扩展,也许是Inchoo的。我可以让这些结果显示在区块中,你如何解决这个问题?我也有同样的问题。@pavankumar