1

I have a working extension that show reviews, but sometimes there's an error in the system.log file, and I don't know why?

var/log/system.log:

[2023-10-26T11:20:42.925466+00:00] main.CRITICAL: Class "Company\AllReviews\Block\AllReviews" does not exist [] []

The extension resides in:

\app\code\Company\Reviews\Block\AllReviews.php
\app\code\Company\Reviews\Block\Reviews.php

The file AllReviews.php ( allreviews.phtml) shows all reviews, and Reviews.php (reviews.phtml) only shows the 25 latest reviews.

Layout file:

\app\design\frontend\Smartwave\company_default\Magento_Review\layout\default.xml


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="reviews">
        <block class="Company\Reviews\Block\Reviews" template="magento_review::reviews.phtml" />
    </referenceBlock>
    <referenceBlock name="allreviews">
        <block class="Company\Reviews\Block\AllReviews" template="magento_review::allreviews.phtml" />
    </referenceBlock>
</body>
</page>

Template files location:

\app\design\frontend\Smartwave\company_default\Magento_Review\templates\allreviews.phtml
\app\design\frontend\Smartwave\company_default\Magento_Review\templates\reviews.phtml

--- post update ---

This is the beginning of the file AllReviews.php

<?php
namespace Company\Reviews\Block;
use Magento\Framework\View\Element\Template;
class AllReviews extends Template {
protected $customerSession;
protected $_storeManager;
...

This is the beginning of the file Reviews.php

<?php
namespace Company\Reviews\Block;
use Magento\Framework\View\Element\Template;
class Reviews extends Template {
protected $customerSession;
protected $_storeManager;
...
2
  • 1
    Can you share the code of these two files as well : \app\code\Company\Reviews\Block\AllReviews.php \app\code\Company\Reviews\Block\Reviews.php Oct 27, 2023 at 10:19
  • I have updated to post with some PHP code from AllReviews.php and Reviews.php (the files are huge, hoping this is enough?). Thanks,
    – Aknot
    Oct 29, 2023 at 13:21

1 Answer 1

1

It's seems to be namespace issue somewhere in your file you can track using "grep -r 'AllReviews'" in your files and then replace with Reviews and also in your default.xml file change the template name magento_review to Magento_Review.

1
  • Can't see any issues since we flushed the Redis db's and changed the template names with capital letters. Thank you!
    – Aknot
    Oct 30, 2023 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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