- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2018
03:20 AM
03-07-2018
03:20 AM
PHP Fatal error: Call to a member function getRatingSummary
Hi,
My webshop is offlline and I can not acces both the admin panel or frontend, "
Exception printing is disabled by default for security reasons.
Error log record number: 1188968715773"
The error_log file says :
[10-Feb-2018 03:41:45 Europe/Amsterdam] PHP Fatal error: Call to a member function getRatingSummary() on null in /public_html/app/design/frontend/mgstheme/ethan/template/catalog/product/view.phtml on line 369
<div itemtype="http://schema.org/AggregateRating" itemscope="" itemprop="aggregateRating"> <?php $rating_summary = $_product->getRatingSummary();?> <meta itemprop="ratingValue" content="<?php echo $rating_summary->getRatingSummary()/20; ?>"> <meta itemprop="ratingCount" content="<?php echo $rating_summary->getReviewsCount(); ?>"> </div>
Does anyone know what I have to do? It returns a NULL?
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018
10:23 PM
03-08-2018
10:23 PM
Re: PHP Fatal error: Call to a member function getRatingSummary
Hello Moerdoe,
You simply need to add the following line to your code start.
$_product = Mage::registry('current_product');
and your final code will look like this.
<php $_product = Mage::registry('current_product'); ?> <div itemtype="http://schema.org/AggregateRating" itemscope="" itemprop="aggregateRating"> <?php $rating_summary = $_product->getRatingSummary();?> <meta itemprop="ratingValue" content="<?php echo $rating_summary->getRatingSummary()/20; ?>"> <meta itemprop="ratingCount" content="<?php echo $rating_summary->getReviewsCount(); ?>"> </div>
Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer