Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 警告:get_class()要求参数1为对象,给定布尔值_Magento_Magento 1.7 - Fatal编程技术网

Magento 警告:get_class()要求参数1为对象,给定布尔值

Magento 警告:get_class()要求参数1为对象,给定布尔值,magento,magento-1.7,Magento,Magento 1.7,我遇到了一个以前以某种方式发布在这里的问题,但从未针对这个案例。通常,这个错误发生在App.php中,但对我来说,它发生在我下面指出的第42行的/httpdocs/App/design/frontend/default/theme/template/catalog/category/view.phtml中 有人知道如何解决这个问题吗?我有点不知所措 <?php /** * Category view template * * @see Mage

我遇到了一个以前以某种方式发布在这里的问题,但从未针对这个案例。通常,这个错误发生在App.php中,但对我来说,它发生在我下面指出的第42行的/httpdocs/App/design/frontend/default/theme/template/catalog/category/view.phtml中

有人知道如何解决这个问题吗?我有点不知所措

    <?php
    /**
     * Category view template
     *
     * @see Mage_Catalog_Block_Category_View
     */
    ?>
    <?php
    $_helper    = $this->helper('catalog/output');
    $_category  = $this->getCurrentCategory();
    $_imgHtml   = '';

    $_category->setCanShowBlock(false);
    $_category->setHasHeaderImage(false);
    //////Line 42///////    if (get_class($this->getLayout()->getBlock('catalog.leftnav')) != 'Mage_Catalog_Block_Navigation') {
        $_category->setCanShowBlock($this->getLayout()->getBlock('mana.catalog.leftnav')->canShowBlock());
    }

    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" />';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        $_category->setHasHeaderImage(true);
    }
?>

<?php /*

<!-- <div class="page-title category-title">
    <?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        <a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
    <?php endif; ?>
    <h1><img src="<?php echo $this->getSkinUrl('images/' . $_helper->categoryAttribute($_category, $_category->getName(), 'name') . '.jpg') ?>" alt="<?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>" /></h1>
</div> -->

*/ 

Mage::getModel('core/session')->setHasAdditionalDescription(false);
?>

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<div id="category_top_image"<?php if ($_category->getCanShowBlock()): ?> style="margin-left: -280px;"<?php endif ?>>

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

<?php if(strtolower($_category->getHideTitle()) != 'yes'): ?>
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php endif ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
<?php endif; ?>

</div>

<?php if($this->isContentMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>

<?php elseif($this->isMixedMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>
        <?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
            <?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
            <?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
        <?php endif; ?>    
    <?php echo $this->getProductListHtml() ?>

<?php else: ?>
    <?php if($_description=$this->getCurrentCategory()->getAdditionalDescription()): ?>
            <?php Mage::getModel('core/session')->setHasAdditionalDescription(true) ?>
<div class="category-additional-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'additional_description') ?>
</div>
    <?php endif; ?>
    <?php echo $this->getProductListHtml() ?>
<?php endif; ?>


这个错误意味着页面上没有名为catalog.leftnav的块,因此您应该检查布局。实际上,这种检查类的方法是不好的,因为它会导致这样的错误。如果某个扩展将重写Mage_Catalog_Block_导航类,也会出现问题

因此,我不确定您为什么要检查该块的类,但如果您确实需要它,我建议您使用风险较小且易于重写的方法:

if ($block = $this->getLayout()->getBlock('catalog.leftnav') && $block instanceof Mage_Catalog_Block_Navigation) {
    ...
}

发生错误的类别是否为锚点?