php - Showing units sold in product page OpenCartv3 -
i'm trying show units sold each product in product page in opencart v3 keep getting following error
fatal error: uncaught error: call member function getunitssold() on null in /applications/xampp/xamppfiles/htdocs/store/catalog/controller/product/product.php:157 stack trace: #0 /applications/xampp/xamppfiles/htdocs/store/system/engine/action.php(79): controllerproductproduct->index() #1 /applications/xampp/xamppfiles/htdocs/store/catalog/controller/startup/router.php(25): action->execute(object(registry)) #2 /applications/xampp/xamppfiles/htdocs/store/system/engine/action.php(79): controllerstartuprouter->index() #3 /applications/xampp/xamppfiles/htdocs/store/system/engine/router.php(67): action->execute(object(registry)) #4 /applications/xampp/xamppfiles/htdocs/store/system/engine/router.php(56): router->execute(object(action)) #5 /applications/xampp/xamppfiles/htdocs/store/system/framework.php(168): router->dispatch(object(action), object(action)) #6 /applications/xampp/xamppfiles/htdocs/store/system/startup.php(104): require_once('/applications/x...') #7 /applications/xampp/xamppfiles/htdocs/store/index.php(19): in /applications/xampp/xamppfiles/htdocs/store/catalog/controller/product/product.php on line 157
what have far is
catalog/model/catalog/product.php
public function getunitssold($product_id) { $query = $this->db->query("select sum(op.quantity) total `" . db_prefix . "order_product` op left join `" . db_prefix . "order` o on (op.order_id = o.order_id) o.order_status_id > '0' , op.product_id = '" . (int)$product_id . "'"); if ($query->row) { return $query->row['total']; } else { return false; } }
and in catalog/controller/product/product.php
$data['text_units_sold'] = $this->language->get('text_units_sold'); $this->data['units_sold'] = $this->model_catalog_product->getunitssold($product_id);
anyone can detect problem , solution.
thanks.
i suspect in function calling getunitssold, have not done
$this->load->model('catalog/product');
Comments
Post a Comment