0

我有一个模板文件和很长的一天。谁能看到我错过了什么。以下内容应该返回搜索结果,但始终返回没有要显示的产品。我正在使用 netbeans,这似乎与 getNoteMessages()): ?> 行有问题,说这是一个变量的意外分配,但我确信编写它的人这样做是有原因的。将其更改为 == 似乎无论如何都没有任何影响。想法?疲劳的...

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

1 回答 1

0

这条线没有问题:

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

Netbeans 总是会抱怨这一点,因为它认为您在分配值而不是检查相等性方面犯了一个常见错误,而实际上您是在此处的同一语句中分配和检查相等性。

您是否刷新了 magento 中的索引?尝试这样做,然后再次搜索。

于 2013-02-01T11:01:26.467 回答