2013-02-01 53 views
0

我有一個模板文件和一個非常漫長的一天。任何人都可以看到我缺少的東西。 下面是應該返回搜索結果,但總是返回沒有產品顯示。我正在使用netbeans,它似乎與getNoteMessages()一行有問題:?>說這是一個意外的變量賦值,但我確信編寫它的人員出於某個原因做了這個。無論如何,將它更改爲==似乎沒有任何影響。思考?累了...Magento - 商店搜索出錯,始終沒有結果。

<div class="page-head"> 
     <h3><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogSearch')->getEscapedQueryText()) ?></h3> 
    </div> 
    <?php if($this->getResultCount()): ?> 
    <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?> 
    <div class="page-head"> 
     <?php if ($this->helper('rss/catalog')->getTagFeedUrl()): ?> 
      <a href="<?php echo $this->helper('rss/catalog')->getTagFeedUrl() ?>" class="nobr link-feed"><?php echo $this->__('Subscribe to Feed') ?></a> 
     <?php endif; ?> 
     <h4><?php echo $this->__("Products"); ?></h4> 
    </div> 
     <?php if ($messages = $this->getNoteMessages()):?> 
      <div class="note-msg"> 
       <?php foreach ($messages as $message):?> 
       <?php echo $message?><br /> 
       <?php endforeach;?> 
      </div> 
     <?php endif; ?> 
     <?php echo $this->getProductListHtml() ?> 
    <?php else: ?> 
    <div class="page-head"> 
     <h4><?php echo $this->__("Products"); ?></h4> 
    </div> 
     <div class="note-msg"> 
      <?php echo ($this->getNoResultText()) ? $this->getNoResultText() : $this->__('There are no results.') ?> 
      <?php if ($messages = $this->getNoteMessages()):?> 
       <?php foreach ($messages as $message):?> 
       <br /><?php echo $message?> 
       <?php endforeach;?> 
      <?php endif; ?> 
     </div> 
    <?php endif; ?> 
    <div class="clear"><p></p></div> 
    <?php if (Mage::helper('searchautocomplete')->isSearchCms()): ?> 
     <div class="page-head"> 
      <h4><?php echo $this->__("CMS Pages"); ?></h4> 
     </div> 
     <?php if($this->getPageResultCount()): ?> 
       <?php $pageCollection = $this->_getPageCollection(); ?> 
       <ul> 
       <?php foreach ($pageCollection as $page) : ?> 
           <li><a href="<?php echo rtrim(Mage::getUrl($page->getIdentifier() == Mage::getStoreConfig('web/default/cms_home_page') ? '/' : $page->getIdentifier()),'/') ?>"><?php echo $page->getTitle(); ?></a><p><?php echo $this->_sanitizeContent($page); ?></p></li> 
       <?php endforeach; ?> 
       </ul> 
     <?php else: ?> 
      <div class="note-msg"> 
       <?php echo $this->__('There are no results.') ?> 
      </div> 
     <?php endif; ?> 
    <?php endif; ?> 
    <?php if (Mage::helper('searchautocomplete')->isSearchBlog()): ?> 
     <div class="page-head"> 
      <h4><?php echo $this->__("Blog Posts"); ?></h4> 
     </div> 
     <?php $blogCollection = $this->_getBlogCollection(); ?> 
     <?php if(count($blogCollection)): ?> 
       <ul> 
       <?php foreach ($blogCollection as $post) : ?> 
           <li><a href="<?php echo rtrim(Mage::getUrl('blog/'.$post->getIdentifier()),'/') ?>"><?php echo $post->getTitle(); ?></a><p><?php echo $this->_sanitizeContent($post); ?></p></li> 
       <?php endforeach; ?> 
       </ul> 
     <?php else: ?> 
      <div class="note-msg"> 
       <?php echo $this->__('There are no results.') ?> 
      </div> 
     <?php endif; ?> 
    <?php endif; ?> 
    <?php if (Mage::helper('searchautocomplete')->isSearchCmspro()): ?> 
     <div class="page-head"> 
      <h4><?php echo $this->__("News Pages"); ?></h4> 
     </div> 
     <?php $news = $this->_getNewsCollection(); ?> 
     <?php if(count($news)): ?> 
       <ul> 
       <?php foreach ($news as $n) : ?> 
        <?php $url = Mage::getModel('core/url_rewrite')->load($n->getUrlRewriteId());?> 
        <li><a href="<?php echo Mage::getBaseUrl().$url->getRequestPath();?>"><?php echo $n->getTitle(); ?></a><p><?php echo $this->_sanitizeContent($n); ?></p></li> 
       <?php endforeach; ?> 
       </ul> 
     <?php else: ?> 
      <div class="note-msg"> 
       <?php echo $this->__('There are no results.') ?> 
      </div> 
     <?php endif; ?> 
    <?php endif; ?> 

回答

0

有沒有與此行的問題:

<?php if ($messages = $this->getNoteMessages()):?> 

NetBeans將一直抱怨說,因爲它認爲你是在分配一個值,而不是檢查平等作出一個常見的錯誤,當事實上你在這裏分配和檢查相同的語句中的平等。

您是否刷新了magento中的索引?嘗試做到這一點,然後再次搜索。

+0

是的,不幸的是我試過...我也嘗試用原始基礎文件的代碼替換我的模板,它仍然是壞的。想想還有其他的東西在起作用。配置一切似乎也是正確的。我想知道是否值得禁用和重新啓用所有產品。 –

+0

你確定他們沒有設置爲「可見性」=隱藏嗎? – Andrew