【发布时间】:2014-01-16 19:54:09
【问题描述】:
在访问我们 Magento 网站上的产品详细信息页面时,我间歇性地收到以下错误...
Call to member function getId() on a non-object in view.phtml (line 70)
这个错误引用的代码可以在下面找到...
<?php
$current_category = Mage::registry('current_category');
$current_id = $current_category->getId();
?>
我使用代码的原因是为了显示特定于这些类别中产品的内容。一个例子可以在下面看到......
<?php if(($current_category) && ($current_id == 717)):?>
// Code Here
<?php endif; ?>
我不知道为什么这个错误会间歇性出现,或者是否有办法用其他东西完全替换代码但得到相同的最终结果。我真的很愿意,但希望能在这件事上提供任何帮助。
非常感谢!
【问题讨论】: