0

I'm trying to open the product detail page from the listing page but its not working, and its showing the below error:

2 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: Magento\Review\Block\Product\Review
Exception #1 (ReflectionException): Class Magento\Review\Block\Product\Review does not exist

Can anyone please help me to rectify this error?

When I try to open the product page, its not opening and I can see the below error in view-source:

<meta property="og:type" content="product" />
<meta property="og:title" content="<br />
<b>Fatal error</b>:  Uncaught Error: Call to a member function getName() on null in /var/www/html/vendor/magento/module-catalog/view/frontend/templates/product/view/opengraph/general.phtml:13
Stack trace:
#0 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include()
#1 /var/www/html/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(vendor\module\Block\Index\Index), '/var/www/html/v...', Array)
#2 /var/www/html/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView('/var/www/html/v...')
#3 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1094): Magento\Framework\View\Element\Template-&gt;_toHtml()
#4 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1098): Magento\Framework\View\Element\AbstractBlock-&gt;Magento\Framework\View\Element\{closure}()
#5 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(671): Magento\Framework\View\Element\Abst in <b>/var/www/html/vendor/magento/module-catalog/view/frontend/templates/product/view/opengraph/general.phtml</b> on line <b>13</b><br />
0

try to run the command to re generate class

sudo php bin/magento setup:di:compile

|improve this answer|||||
  • I have done that but still its showing the error – Siva Mar 3 at 6:23
0

Check the constructor. Problem is with the Constructor params . After fixing it run di:compile

|improve this answer|||||
0

Check Whether Magento\Review\Block\Product\Review is overridden. If so, then cross check the block extends type.

Also, check the catalog_product_view.xml file whether the review block class is mentioned correctly as

<block class="Magento\Review\Block\Product\Review" name="reviews.tab" as="reviews" template="Magento_Review::review.phtml" group="detailed_info" ifconfig="catalog/review/active">

If everything is correctly, Please follow below steps

1) rm -rf var/* pub/static/* generated/* (to remove all cache, static content and generated files)

2) php bin/magento setup:upgrade && php bin/magento setup:di:compile && php bin/magento setup:static-content:deploy -f

Note: Use -f if you are in developer mode.

|improve this answer|||||
  • I have updated the question, please check @Sathishkumar – Siva Mar 3 at 10:27
  • @Siva, I noticed the product name itself not getting and throwing an error. Have you done any migration of DB. Also, check the admin panel whether the product is available. If so, try to edit and save it. – Sathishkumar Mar 3 at 13:48

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.