Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Почему получаю ошибку Fatal error: Uncaught Error: Call to a member function getTotalReviews() on null?


Recommended Posts

Есть модуль с отзывами. Пыиюсь в админке вывести уведомление о новом отзыве admin/controller/catalog/p_review.php: 

$p_review_total = $this->model_catalog_p_review->getTotalReviews();
$data['p_reviewtotal'] = $p_review_total;

$results = $this->model_catalog_p_review->getReviews($filter_data);


header.php

// Reviews
$this->load->model('catalog/p_review');

$p_reviewtotal = $this->model_catalog_p_review->getTotalReviews(array('status' => 0));

$data['p_reviewtotal'] = $p_reviewtotal;

$data['p_review'] = $this->url->link('catalog/p_review', 'user_token=' . $this->session->data['user_token'] . '&status=0', true);

header.twig

 

    {% if p_review_total >= 1 %}
      <li class="dropdown"><a href="{{ p_review }}"> <i class="fa fa fa-comments-o fa-lg blinking" style="color:green"></i> <span style="font-size: 10px">{{ text_review }}</span> <sub>{{ text_new_review }}: ({{ review_total }})</sub></a></li>
   {% endif %}

 

Получаю ошибку

Fatal error: Uncaught Error: Call to a member function getTotalReviews() on null

Как правильно вывести когдачество?

Link to comment
Share on other sites


Решил проблему ик: 
header.php

$this->load->model('catalog/p_review');

$p_review_total = $this->model_sale_order->getTotalReviews('');
$data['p_review_total'] = $p_review_total;

$data['review'] = $this->url->link('catalog/p_review', 'user_token=' . $this->session->data['user_token'] . '&status=0', true);

model/p_review.php

public function getTotalReviews($status) {
    $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "p_review WHERE status = '" . $status . "'");
    return $query->row['total'];
}





 

Link to comment
Share on other sites


  • 2 years later...

Аналогичная проблема :  Fatal error: Uncaught Error: Call to a member function getTotalReviewsByProductId() on null in /home/wm35867/domains/site.ru/storage/modification/catalog/controller/product/product.php:1259 Stack trace: #0 /home/wm35867/domains/site.ru/storage/modification/system/engine/action.php(79(sad) ControllerProductProduct->index() #1 /home/wm35867/domains/site.ru/public_html/catalog/controller/startup/router.php(25(sad) Action->execute(Object(Registry)) #2 /home/wm35867/domains/site.ru/storage/modification/system/engine/action.php(79(sad) ControllerStartupRouter->index() #3 /home/wm35867/domains/site.ru/storage/modification/system/engine/router.php(76(sad) Action->execute(Object(Registry)) #4 /home/wm35867/domains/site.ru/storage/modification/system/engine/router.php(65(sad) Router->execute(Object(Action)) #5 /home/wm35867/domains/site.ru/public_html/system/framework.php(191(sad) Router->dispatch(Object(Action), Object(Action)) #6 /home/wm35867/domains/site.ru/public_html/system/startup.php(104(sad) require_once('/home/ in /home/wm35867/domains/site.ru/storage/modification/catalog/controller/product/product.php on line 1259

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.