在view.pthml中的非对象上调用成员函数getItemsCount()

时间:2013-07-19 04:33:13

标签: magento magento-1.7

致命错误:在非对象

上调用成员函数getItemsCount()

位于第49行的\ app \ design \ frontend \ default \ jorg \ template \ catalog \ layer \ view.phtml

可以提供任何帮助。

Magento 1.7

<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
    <div class="block-title">
        <strong><span><?php echo $this->__('Shop By') ?></span></strong>
</div>
<div class="block-content">
    <?php echo $this->getStateHtml() ?>
    <?php if ($this->getLayer()->getState()->getFilters()): ?>
        <div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
    <?php endif; ?>
    <?php if($this->canShowOptions()): ?>
        <p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
        <dl id="narrow-by-list">
            <?php $_filters = $this->getFilters() ?>              
            <?php foreach ($_filters as $_filter): ?>
            <?php if($_filter->getItemsCount()): ?>
                <dt><?php echo $this->__($_filter->getName()) ?></dt>
                <dd><?php echo $_filter->getHtml() ?></dd>
            <?php endif; ?>
            <?php endforeach; ?>             
        </dl>
        <script type="text/javascript">decorateDataList('narrow-by-list')</script>
    <?php endif; ?>
</div>

1 个答案:

答案 0 :(得分:0)

您可以调试可能的错误原因

  1. put var_dump(get_class($ this)); exit;在第一行的.phtml中=&gt;然后去上课并展示方法getFilters()
  2. 显示对象的类型返回方法getFilters()
    1. 可以返回$ this - &gt;是在当前的班级
    2. 或者可以是另一种类型的对象 - &gt;转到对象类型
  3. 在第二步的对象类中搜索方法getItemsCount()。显示此方法的返回值。
  4. 你是活跃的开发者模式吗?如果出现错误,这可以向您显示更多信息。