6

我已经安装了 Magento CE 1.9 版本并在主页上调用目录后出现错误。问题似乎与list.phtml有关。

错误:致命错误:在第 74 行的 mageinc\app\design\frontend\rwd\default\template\catalog\product\list.phtml 中的非对象上调用成员函数getSortedChildren()

安装后我没有更改任何内容,而且这个问题似乎是 Magento 1.9 版本出现的。

目录页面上的列表和网格视图都出现问题,因为这两个视图都被调用。

有没有解决这个问题的最佳解决方案?

4

6 回答 6

5

你只需要删除第->getSortedChildren();134 行的方法

$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();

所以你有了

$_nameAfterChildren = $this->getChild('name.after');
于 2014-06-24T15:56:29.233 回答
2

在块部分布局文件中添加这些行

     <block type="core/text_list" name="product_list.name.after" as="name.after"/>
     <block type="core/text_list" name="product_list.after" as="after"/>
于 2014-07-22T12:47:54.160 回答
1

将代码替换为:

<?php
$_nameAfter = $this->getChild('name.after');
// New if here
if($_nameAfter):
    $_nameAfterChildren = $_nameAfter->getSortedChildren();
    foreach($_nameAfterChildren as $_nameAfterChildName):
        $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
        $_nameAfterChild->setProduct($_product);
        ?>
        <?php echo $_nameAfterChild->toHtml(); ?>
    <?php endforeach; ?>
<?php endif; ?>

<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after');
if ($_afterChildren):
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach($_afterChildren as $_afterChildName):
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        $_afterChild->setProductCollection($_productCollection);
    ?>
    <?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
<?php endif; ?>

如中所示:https ://magento.stackexchange.com/questions/20984/show-products-on-homepage-magento-1-9/20996#20996?newreg=c5c83466c28d45259ed36642cfe0a382

于 2014-09-09T23:31:03.103 回答
0

编辑此文件 app/design/frontend/rwd/default/template/catalog/product/list.phtml 在 73 和 135 行添加此代码

                <?php if(!empty($nameAfter = $this->getChild('name.after'))): ?>

就在之前:

                    $_nameAfterChildren = $nameAfter->getSortedChildren();

并在 82 和 144 行添加此代码

                <?php endif; ?>

紧接着

                <?php endforeach; ?>
于 2014-06-11T06:21:06.753 回答
0

The solution of Pass TeT will throw the PHP Error "PHP Fatal error: Can't use method return value in write context" because PHP doesn't have concept of emptyness. It's better to use <?php if($this->getChild('name.after')): ?> what wouldn't throw an error.

于 2015-03-14T13:14:50.467 回答
-1

嘿伙计们我有同样的问题 - 但这是因为我没有将所有文件从 app/default/default 复制

app/yourTheme/default

我在默认目录中丢失了文件。据我了解 - 所有文件都需要复制。
/etc
/布局
/本地
/模板

于 2014-09-05T00:25:37.563 回答