Post by fido-x » Fri Jan 23, 2009 3:27 pm

In the admin, when no products have been viewed an error message is generated, stating --
Warning: Division by zero in admin/controller/report_viewed.php on line 38

Suggest changing lines 34-40 (in admin/controller/report_viewed.php) from

Code: Select all

foreach ($results as $result) {
  $product_data[] = array(
    'name'    => $result['name'],
    'viewed'  => $result['viewed'],
    'percent' => round(($result['viewed'] / $total) * 100, 2) . '%'
  );
}
to

Code: Select all

foreach ($results as $result) {
  if ($total == '0') {
    $percent = '0';
  } else {
    $percent = round(($result['viewed'] / $total) * 100, 2);
  }
  $product_data[] = array(
    'name'    => $result['name'],
    'viewed'  => $result['viewed'],
    'percent' => $percent . '%'
  );
}
Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by hm2k » Fri Jan 23, 2009 7:41 pm

Fixed in r373

UK Web Hosting


User avatar
Global Moderator

Posts

Joined
Tue Mar 11, 2008 9:06 am
Location - UK
Who is online

Users browsing this forum: No registered users and 2 guests