  |
14 | 14 | | var $_data = array(); |
| |
15 | 15 | | |
| |
16 | 16 | | function osC_Product($id) { |
  |
17 | | - | global $osC_Database; |
| |
| 17 | + | global $osC_Database, $osC_Services; |
|
18 | 18 | | |
| |
19 | 19 | | $Qproduct = $osC_Database->query('select pd.products_name as name, pd.products_description as description, p.products_model as model, p.products_quantity as quantity, p.products_image as image, pd.products_url as url, p.products_price as price, p.products_tax_class_id as tax_class_id, p.products_date_added as date_added, p.products_date_available as date_available, p.manufacturers_id from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id'); |
| |
20 | 20 | | $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); |
| |
|
|
 |
… |
|
52 | 52 | | 'price_prefix' => $Qattributes->value('price_prefix')); |
| |
53 | 53 | | } |
| |
54 | 54 | | } |
  |
| 55 | + | |
| |
| 56 | + | if ($osC_Services->isStarted('reviews')) { |
| |
| 57 | + | $Qavg = $osC_Database->query('select avg(reviews_rating) as rating from :table_reviews where products_id = :products_id and languages_id = :languages_id and reviews_status = 1'); |
| |
| 58 | + | $Qavg->bindTable(':table_reviews', TABLE_REVIEWS); |
| |
| 59 | + | $Qavg->bindInt(':products_id', $id); |
| |
| 60 | + | $Qavg->bindInt(':languages_id', $_SESSION['languages_id']); |
| |
| 61 | + | $Qavg->execute(); |
| |
| 62 | + | |
| |
| 63 | + | $this->_data['reviews_average_rating'] = round($Qavg->value('rating')); |
| |
| 64 | + | } |
|
55 | 65 | | } |
| |
56 | 66 | | |
  |
| 67 | + | function getData($key) { |
| |
| 68 | + | if (isset($this->_data[$key])) { |
| |
| 69 | + | return $this->_data[$key]; |
| |
| 70 | + | } |
| |
| 71 | + | |
| |
| 72 | + | return false; |
| |
| 73 | + | } |
| |
| 74 | + | |
  |
57 | 75 | | function getID() { |
| |
58 | 76 | | return $this->_data['id']; |
| |
59 | 77 | | } |