Possible Duplicate:
Any reason why Mage::registry(‘current_category’) would return NULL?
Reference - What does this error mean in PHP?如何禁止致命錯誤:調用成員函數?
致命錯誤:調用一個成員函數getParentCategory()一個非對象在...
代碼:
$_category_detail=Mage::registry('current_category');
$id=$_category_detail->getParentCategory()->getId();
現在,當頁面無法使用getParentCategory()我使用以下,但不能工作。
if(isset(getParentCategory()){
$id=$_category_detail->getParentCategory()->getId();
}
爲什麼?謝謝
如果'$ _category_detail'不是一個有效的對象不觸發它的錯誤? – Shoe
它不會 - 只是自己測試它...文檔也不測試或觸發錯誤;)只是返回'false' –