  |
17 | 17 | | global $osC_Database, $osC_Services, $osC_Language, $osC_Image; |
| |
18 | 18 | | |
| |
19 | 19 | | if (!empty($id)) { |
  |
20 | | - | $Qproduct = $osC_Database->query('select p.products_id as id, p.products_quantity as quantity, 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, pd.products_name as name, pd.products_description as description, pd.products_model as model, pd.products_keyword as keyword, pd.products_tags as tags, pd.products_url as url, i.image from :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where'); |
| |
| 20 | + | $Qproduct = $osC_Database->query('select p.products_id as id, p.products_quantity as quantity, 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, pd.products_name as name, pd.products_description as description, pd.products_model as model, pd.products_keyword as keyword, pd.products_tags as tags, pd.products_url as url from :table_products p, :table_products_description pd where'); |
|
21 | 21 | | $Qproduct->bindTable(':table_products', TABLE_PRODUCTS); |
  |
22 | | - | $Qproduct->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); |
|
23 | 22 | | $Qproduct->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); |
| |
24 | 23 | | |
| |
25 | 24 | | if (is_numeric($id) || ereg('[0-9]+[{[0-9]+}[0-9]+]*$', $id)) { |
| |
|
|
 |
… |
|
31 | 30 | | } |
| |
32 | 31 | | |
| |
33 | 32 | | $Qproduct->appendQuery('and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id'); |
  |
34 | | - | $Qproduct->bindInt(':default_flag', 1); |
|
35 | 33 | | $Qproduct->bindInt(':language_id', $osC_Language->getID()); |
| |
36 | 34 | | $Qproduct->execute(); |
| |
37 | 35 | | |
| |
38 | 36 | | if ($Qproduct->numberOfRows() === 1) { |
| |
39 | 37 | | $this->_data = $Qproduct->toArray(); |
| |
40 | 38 | | |
  |
| 39 | + | $this->_data['images'] = array(); |
| |
| 40 | + | |
| |
| 41 | + | $Qimages = $osC_Database->query('select id, image, default_flag from :table_products_images where products_id = :products_id order by sort_order'); |
| |
| 42 | + | $Qimages->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES); |
| |
| 43 | + | $Qimages->bindInt(':products_id', $this->_data['id']); |
| |
| 44 | + | $Qimages->execute(); |
| |
| 45 | + | |
| |
| 46 | + | while ($Qimages->next()) { |
| |
| 47 | + | $this->_data['images'][] = $Qimages->toArray(); |
| |
| 48 | + | } |
| |
| 49 | + | |
|
41 | 50 | | $Qcategory = $osC_Database->query('select categories_id from :table_products_to_categories where products_id = :products_id limit 1'); |
| |
42 | 51 | | $Qcategory->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); |
| |
43 | 52 | | $Qcategory->bindInt(':products_id', $this->_data['id']); |
| |
|
|
 |
… |
|
156 | 165 | | return $this->_data['category_id']; |
| |
157 | 166 | | } |
| |
158 | 167 | | |
  |
| 168 | + | function getImages() { |
| |
| 169 | + | return $this->_data['images']; |
| |
| 170 | + | } |
| |
| 171 | + | |
|
159 | 172 | | function hasImage() { |
  |
160 | | - | return (isset($this->_data['image']) && !empty($this->_data['image'])); |
| |
| 173 | + | foreach ($this->_data['images'] as $image) { |
| |
| 174 | + | if ($image['default_flag'] == '1') { |
| |
| 175 | + | return true; |
| |
| 176 | + | } |
| |
| 177 | + | } |
|
161 | 178 | | } |
| |
162 | 179 | | |
| |
163 | 180 | | function getImage() { |
  |
164 | | - | return $this->_data['image']; |
| |
| 181 | + | foreach ($this->_data['images'] as $image) { |
| |
| 182 | + | if ($image['default_flag'] == '1') { |
| |
| 183 | + | return $image['image']; |
| |
| 184 | + | } |
| |
| 185 | + | } |
|
165 | 186 | | } |
| |
166 | 187 | | |
| |
167 | 188 | | function hasURL() { |
| |
|
|
 |
… |
|
243 | 264 | | $Qupdate->execute(); |
| |
244 | 265 | | } |
| |
245 | 266 | | |
  |
| 267 | + | function numberOfImages() { |
| |
| 268 | + | return sizeof($this->_data['images']); |
| |
| 269 | + | } |
| |
| 270 | + | |
  |
246 | 271 | | function &getListingNew() { |
| |
247 | 272 | | global $osC_Database, $osC_Language, $osC_Image; |
| |
248 | 273 | | |