2013-07-25 106 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沒有記錄任何關於這一點。 –

相關問題