  |
33 | 33 | | $Qproduct->bindInt(':language_id', $_SESSION['languages_id']); |
| |
34 | 34 | | $Qproduct->execute(); |
| |
35 | 35 | | |
  |
36 | | - | $this->_data = $Qproduct->toArray(); |
| |
| 36 | + | if ($Qproduct->numberOfRows() === 1) { |
| |
| 37 | + | $this->_data = $Qproduct->toArray(); |
|
37 | 38 | | |
  |
38 | | - | $Qcheck = $osC_Database->query('select products_attributes_id from :table_products_attributes patrib where products_id = :products_id limit 1'); |
| |
39 | | - | $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
40 | | - | $Qcheck->bindInt(':products_id', $this->_data['id']); |
| |
41 | | - | $Qcheck->execute(); |
| |
| 39 | + | $Qcheck = $osC_Database->query('select products_attributes_id from :table_products_attributes patrib where products_id = :products_id limit 1'); |
| |
| 40 | + | $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
| 41 | + | $Qcheck->bindInt(':products_id', $this->_data['id']); |
| |
| 42 | + | $Qcheck->execute(); |
|
42 | 43 | | |
  |
43 | | - | if ($Qcheck->numberOfRows() === 1) { |
| |
44 | | - | $this->_data['attributes'] = array(); |
| |
| 44 | + | if ($Qcheck->numberOfRows() === 1) { |
| |
| 45 | + | $this->_data['attributes'] = array(); |
|
45 | 46 | | |
  |
46 | | - | $Qattributes = $osC_Database->query('select pa.*, po.*, pov.* from :table_products_attributes pa, :table_products_options po, :table_products_options_values pov where pa.products_id = :products_id and pa.options_id = po.products_options_id and po.language_id = :language_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id order by po.products_options_name, pov.products_options_values_name'); |
| |
47 | | - | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
48 | | - | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
49 | | - | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
50 | | - | $Qattributes->bindInt(':products_id', $this->_data['id']); |
| |
51 | | - | $Qattributes->bindInt(':language_id', $_SESSION['languages_id']); |
| |
52 | | - | $Qattributes->bindInt(':language_id', $_SESSION['languages_id']); |
| |
53 | | - | $Qattributes->execute(); |
| |
| 47 | + | $Qattributes = $osC_Database->query('select pa.*, po.*, pov.* from :table_products_attributes pa, :table_products_options po, :table_products_options_values pov where pa.products_id = :products_id and pa.options_id = po.products_options_id and po.language_id = :language_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id order by po.products_options_name, pov.products_options_values_name'); |
| |
| 48 | + | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
| 49 | + | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
| 50 | + | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
| 51 | + | $Qattributes->bindInt(':products_id', $this->_data['id']); |
| |
| 52 | + | $Qattributes->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 53 | + | $Qattributes->bindInt(':language_id', $_SESSION['languages_id']); |
| |
| 54 | + | $Qattributes->execute(); |
|
54 | 55 | | |
  |
55 | | - | while ($Qattributes->next()) { |
| |
56 | | - | $this->_data['attributes'][] = array('options_id' => $Qattributes->valueInt('options_id'), |
| |
57 | | - | 'options_name' => $Qattributes->value('products_options_name'), |
| |
58 | | - | 'options_values_id' => $Qattributes->valueInt('options_values_id'), |
| |
59 | | - | 'options_values_name' => $Qattributes->value('products_options_values_name'), |
| |
60 | | - | 'options_values_price' => $Qattributes->value('options_values_price'), |
| |
61 | | - | 'price_prefix' => $Qattributes->value('price_prefix')); |
| |
| 56 | + | while ($Qattributes->next()) { |
| |
| 57 | + | $this->_data['attributes'][] = array('options_id' => $Qattributes->valueInt('options_id'), |
| |
| 58 | + | 'options_name' => $Qattributes->value('products_options_name'), |
| |
| 59 | + | 'options_values_id' => $Qattributes->valueInt('options_values_id'), |
| |
| 60 | + | 'options_values_name' => $Qattributes->value('products_options_values_name'), |
| |
| 61 | + | 'options_values_price' => $Qattributes->value('options_values_price'), |
| |
| 62 | + | 'price_prefix' => $Qattributes->value('price_prefix')); |
| |
| 63 | + | } |
|
62 | 64 | | } |
  |
63 | | - | } |
|
64 | 65 | | |
  |
65 | | - | if ($osC_Services->isStarted('reviews')) { |
| |
66 | | - | $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'); |
| |
67 | | - | $Qavg->bindTable(':table_reviews', TABLE_REVIEWS); |
| |
68 | | - | $Qavg->bindInt(':products_id', $this->_data['id']); |
| |
69 | | - | $Qavg->bindInt(':languages_id', $_SESSION['languages_id']); |
| |
70 | | - | $Qavg->execute(); |
| |
| 66 | + | if ($osC_Services->isStarted('reviews')) { |
| |
| 67 | + | $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'); |
| |
| 68 | + | $Qavg->bindTable(':table_reviews', TABLE_REVIEWS); |
| |
| 69 | + | $Qavg->bindInt(':products_id', $this->_data['id']); |
| |
| 70 | + | $Qavg->bindInt(':languages_id', $_SESSION['languages_id']); |
| |
| 71 | + | $Qavg->execute(); |
|
71 | 72 | | |
  |
72 | | - | $this->_data['reviews_average_rating'] = round($Qavg->value('rating')); |
| |
| 73 | + | $this->_data['reviews_average_rating'] = round($Qavg->value('rating')); |
| |
| 74 | + | } |
|
73 | 75 | | } |
| |
74 | 76 | | } |
| |
75 | 77 | | } |
| |
|
|
 |
… |
|
110 | 112 | | return $this->_data['model']; |
| |
111 | 113 | | } |
| |
112 | 114 | | |
  |
| 115 | + | function hasKeyword() { |
| |
| 116 | + | return (isset($this->_data['keyword']) && !empty($this->_data['keyword'])); |
| |
| 117 | + | } |
| |
| 118 | + | |
|
113 | 119 | | function getKeyword() { |
| |
114 | 120 | | return $this->_data['keyword']; |
| |
115 | 121 | | } |
| |
116 | 122 | | |
  |
| 123 | + | function hasTags() { |
| |
| 124 | + | return (isset($this->_data['tags']) && !empty($this->_data['tags'])); |
| |
| 125 | + | } |
| |
| 126 | + | |
| |
| 127 | + | function getTags() { |
| |
| 128 | + | return $this->_data['tags']; |
| |
| 129 | + | } |
| |
| 130 | + | |
  |
117 | 131 | | function getPrice() { |
| |
118 | 132 | | } |
| |
119 | 133 | | |