1

On clicking home page link to category page, the page shows the following error.

Fatal error: Call to a member function getId() on a non-object in xxxxxxxxxxxxxxx\app\code\core\Mage\Review\Block\Product\View\List.php on line 40

Can anyone help me to fix it?

  • have you changed any code recently ? – Pradeep Sanku Feb 10 '15 at 7:25
  • ya. Actually i have just integrated theme to customer login form. That's all – Praseetha Feb 10 '15 at 7:28
2

I bet you are trying to list the reviews in the product list page.
in case I'm right, it doesn't work like you are doing it. You cannot use Mage_Review_Block_Product_View_List for showing reviews in the product list page.
That block needs to be in a "one single product context" (aka Product page) because it expects Mage::registry('product') to return a valid product model instance.

The solution in your case would be:

  1. Remove the reviews from the product listing page
  2. Use an other block that extends Mage_Review_Block_Product_View_List but with a different getProductId method. Something like this (untested):

    public function getProductId()
    {
        if ($this->getProduct()) {
             return $this->getProduct()->getId();
        }
        return parent::getProductId();
    }
    

now you can get the reviews in the list page like this:

<?php $reviewBlock = Mage::app()->getLayout()->createBlock('[module]/block_alias_here')->setProduct($_product);?>
<?php //do your magic with $reviewBlock?>

where $_product is the current iteration from the product list to be shown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.