|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Divine CMS - Open source CMS for widespread use. |
|
4
|
|
|
Copyright (c) 2019 Mykola Burakov ([email protected]) |
|
5
|
|
|
|
|
6
|
|
|
See SOURCE.txt for other and additional information. |
|
7
|
|
|
|
|
8
|
|
|
This file is part of Divine CMS. |
|
9
|
|
|
|
|
10
|
|
|
This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
it under the terms of the GNU General Public License as published by |
|
12
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
13
|
|
|
(at your option) any later version. |
|
14
|
|
|
|
|
15
|
|
|
This program is distributed in the hope that it will be useful, |
|
16
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
GNU General Public License for more details. |
|
19
|
|
|
|
|
20
|
|
|
You should have received a copy of the GNU General Public License |
|
21
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
22
|
|
|
|
|
23
|
|
|
class ControllerProductProduct extends \Divine\Engine\Core\Controller |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
private $error = array(); |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
public function index() |
|
|
|
|
|
|
28
|
|
|
{ |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
// scripts & styles |
|
31
|
|
|
$this->document->addStyle('/public_html/assets/css/application/page/product/product.css'); |
|
32
|
|
|
$this->document->addStyle('/public_html/assets/css/application/page/product/drift-basic.min.css'); |
|
33
|
|
|
// временно, зависимость для дрифта |
|
34
|
|
|
$this->document->addScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'); |
|
35
|
|
|
$this->document->addScript('/public_html/assets/js/application/page/product/Drift.min.js'); |
|
36
|
|
|
// |
|
37
|
|
|
|
|
38
|
|
|
// language |
|
39
|
|
|
$this->load->language('product/product'); |
|
40
|
|
|
|
|
41
|
|
|
// breadcrumbs |
|
42
|
|
|
$data['breadcrumbs'] = array(); |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
$data['breadcrumbs'][] = array( |
|
45
|
|
|
'text' => $this->language->get('text_home'), |
|
46
|
|
|
'href' => $this->url->link('common/home') |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
$this->load->model('catalog/category'); |
|
50
|
|
|
|
|
51
|
|
|
if (isset($this->request->get['path'])) { |
|
52
|
|
|
$path = ''; |
|
53
|
|
|
|
|
54
|
|
|
$parts = explode('_', (string) $this->request->get['path']); |
|
55
|
|
|
|
|
56
|
|
|
$category_id = (int) array_pop($parts); |
|
57
|
|
|
|
|
58
|
|
|
foreach ($parts as $path_id) { |
|
59
|
|
|
if (!$path) { |
|
60
|
|
|
$path = $path_id; |
|
61
|
|
|
} else { |
|
62
|
|
|
$path .= '_' . $path_id; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$category_info = $this->model_catalog_category->getCategory($path_id); |
|
66
|
|
|
|
|
67
|
|
|
if ($category_info) { |
|
68
|
|
|
$data['breadcrumbs'][] = array( |
|
69
|
|
|
'text' => $category_info['name'], |
|
70
|
|
|
'href' => $this->url->link('product/category', 'path=' . $path) |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
// Set the last category breadcrumb |
|
76
|
|
|
$category_info = $this->model_catalog_category->getCategory($category_id); |
|
77
|
|
|
|
|
78
|
|
|
if ($category_info) { |
|
79
|
|
|
$url = ''; |
|
80
|
|
|
|
|
81
|
|
|
if (isset($this->request->get['sort'])) { |
|
82
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
if (isset($this->request->get['order'])) { |
|
86
|
|
|
$url .= '&order=' . $this->request->get['order']; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if (isset($this->request->get['page'])) { |
|
90
|
|
|
$url .= '&page=' . $this->request->get['page']; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if (isset($this->request->get['limit'])) { |
|
94
|
|
|
$url .= '&limit=' . $this->request->get['limit']; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
$data['breadcrumbs'][] = array( |
|
98
|
|
|
'text' => $category_info['name'], |
|
99
|
|
|
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// manufacturer |
|
105
|
|
|
$this->load->model('catalog/manufacturer'); |
|
106
|
|
|
|
|
107
|
|
|
if (isset($this->request->get['manufacturer_id'])) { |
|
108
|
|
|
$data['breadcrumbs'][] = array( |
|
109
|
|
|
'text' => $this->language->get('text_brand'), |
|
110
|
|
|
'href' => $this->url->link('product/manufacturer') |
|
111
|
|
|
); |
|
112
|
|
|
|
|
113
|
|
|
$url = ''; |
|
114
|
|
|
|
|
115
|
|
|
if (isset($this->request->get['sort'])) { |
|
116
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
if (isset($this->request->get['order'])) { |
|
120
|
|
|
$url .= '&order=' . $this->request->get['order']; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
if (isset($this->request->get['page'])) { |
|
124
|
|
|
$url .= '&page=' . $this->request->get['page']; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
if (isset($this->request->get['limit'])) { |
|
128
|
|
|
$url .= '&limit=' . $this->request->get['limit']; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); |
|
132
|
|
|
|
|
133
|
|
|
if ($manufacturer_info) { |
|
134
|
|
|
$data['breadcrumbs'][] = array( |
|
135
|
|
|
'text' => $manufacturer_info['name'], |
|
136
|
|
|
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) |
|
137
|
|
|
); |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
// search |
|
142
|
|
|
if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { |
|
143
|
|
|
$url = ''; |
|
144
|
|
|
|
|
145
|
|
|
if (isset($this->request->get['search'])) { |
|
146
|
|
|
$url .= '&search=' . $this->request->get['search']; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
if (isset($this->request->get['tag'])) { |
|
150
|
|
|
$url .= '&tag=' . $this->request->get['tag']; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
if (isset($this->request->get['description'])) { |
|
154
|
|
|
$url .= '&description=' . $this->request->get['description']; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
if (isset($this->request->get['category_id'])) { |
|
158
|
|
|
$url .= '&category_id=' . $this->request->get['category_id']; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
if (isset($this->request->get['sub_category'])) { |
|
162
|
|
|
$url .= '&sub_category=' . $this->request->get['sub_category']; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
if (isset($this->request->get['sort'])) { |
|
166
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
if (isset($this->request->get['order'])) { |
|
170
|
|
|
$url .= '&order=' . $this->request->get['order']; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
if (isset($this->request->get['page'])) { |
|
174
|
|
|
$url .= '&page=' . $this->request->get['page']; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
if (isset($this->request->get['limit'])) { |
|
178
|
|
|
$url .= '&limit=' . $this->request->get['limit']; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
$data['breadcrumbs'][] = array( |
|
182
|
|
|
'text' => $this->language->get('text_search'), |
|
183
|
|
|
'href' => $this->url->link('product/search', $url) |
|
184
|
|
|
); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
// product_id |
|
188
|
|
|
if (isset($this->request->get['product_id'])) { |
|
189
|
|
|
$product_id = (int) $this->request->get['product_id']; |
|
190
|
|
|
} else { |
|
191
|
|
|
$product_id = 0; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
// product_info |
|
195
|
|
|
$this->load->model('catalog/product'); |
|
196
|
|
|
|
|
197
|
|
|
$product_info = $this->model_catalog_product->getProduct($product_id); |
|
198
|
|
|
|
|
199
|
|
|
// +++ category-in-the-product-page | All linked categories |
|
200
|
|
|
$querycats = $this->model_catalog_product->getCategories($product_id); |
|
201
|
|
|
$categories = array(); |
|
202
|
|
|
|
|
203
|
|
|
foreach ($querycats as $item) { |
|
204
|
|
|
$categ = $this->model_catalog_category->getCategory($item['category_id']); |
|
205
|
|
|
if ($categ['parent_id'] > 0) { |
|
206
|
|
|
$catinfo['href'] = $this->url->link('product/category', 'path=' . $categ['parent_id'] . '_' . $item['category_id']); |
|
207
|
|
|
} else { |
|
208
|
|
|
$catinfo['href'] = $this->url->link('product/category', 'path=' . $item['category_id']); |
|
209
|
|
|
} |
|
210
|
|
|
$catinfo['name'] = $categ['name']; |
|
211
|
|
|
$categories[] = $catinfo; |
|
|
|
|
|
|
212
|
|
|
} |
|
213
|
|
|
// +++ |
|
214
|
|
|
|
|
215
|
|
|
if ($product_info) { |
|
216
|
|
|
$url = ''; |
|
217
|
|
|
|
|
218
|
|
|
if (isset($this->request->get['path'])) { |
|
219
|
|
|
$url .= '&path=' . $this->request->get['path']; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
if (isset($this->request->get['filter'])) { |
|
223
|
|
|
$url .= '&filter=' . $this->request->get['filter']; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
if (isset($this->request->get['manufacturer_id'])) { |
|
227
|
|
|
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
if (isset($this->request->get['search'])) { |
|
231
|
|
|
$url .= '&search=' . $this->request->get['search']; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
if (isset($this->request->get['tag'])) { |
|
235
|
|
|
$url .= '&tag=' . $this->request->get['tag']; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
if (isset($this->request->get['description'])) { |
|
239
|
|
|
$url .= '&description=' . $this->request->get['description']; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
if (isset($this->request->get['category_id'])) { |
|
243
|
|
|
$url .= '&category_id=' . $this->request->get['category_id']; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
if (isset($this->request->get['sub_category'])) { |
|
247
|
|
|
$url .= '&sub_category=' . $this->request->get['sub_category']; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
if (isset($this->request->get['sort'])) { |
|
251
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
if (isset($this->request->get['order'])) { |
|
255
|
|
|
$url .= '&order=' . $this->request->get['order']; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
if (isset($this->request->get['page'])) { |
|
259
|
|
|
$url .= '&page=' . $this->request->get['page']; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
if (isset($this->request->get['limit'])) { |
|
263
|
|
|
$url .= '&limit=' . $this->request->get['limit']; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
$data['breadcrumbs'][] = array( |
|
267
|
|
|
'text' => $product_info['name'], |
|
268
|
|
|
'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) |
|
269
|
|
|
); |
|
270
|
|
|
|
|
271
|
|
|
if ($product_info['meta_title']) { |
|
272
|
|
|
$this->document->setTitle($product_info['meta_title']); |
|
273
|
|
|
} else { |
|
274
|
|
|
$this->document->setTitle($product_info['name']); |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
if ($product_info['noindex'] <= 0) { |
|
278
|
|
|
$this->document->setRobots('noindex,follow'); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
if ($product_info['meta_h1']) { |
|
282
|
|
|
$data['heading_title'] = $product_info['meta_h1']; |
|
283
|
|
|
} else { |
|
284
|
|
|
$data['heading_title'] = $product_info['name']; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
$this->document->setDescription($product_info['meta_description']); |
|
288
|
|
|
$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); |
|
289
|
|
|
|
|
290
|
|
|
$data['text_select'] = $this->language->get('text_select'); |
|
291
|
|
|
$data['text_manufacturer'] = $this->language->get('text_manufacturer'); |
|
292
|
|
|
$data['text_model'] = $this->language->get('text_model'); |
|
293
|
|
|
$data['text_reward'] = $this->language->get('text_reward'); |
|
294
|
|
|
$data['text_points'] = $this->language->get('text_points'); |
|
295
|
|
|
$data['text_stock'] = $this->language->get('text_stock'); |
|
296
|
|
|
$data['text_discount'] = $this->language->get('text_discount'); |
|
297
|
|
|
$data['text_option'] = $this->language->get('text_option'); |
|
298
|
|
|
$data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); |
|
299
|
|
|
$data['text_write'] = $this->language->get('text_write'); |
|
300
|
|
|
$data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); |
|
301
|
|
|
$data['text_note'] = $this->language->get('text_note'); |
|
302
|
|
|
$data['text_tags'] = $this->language->get('text_tags'); |
|
303
|
|
|
$data['text_related'] = $this->language->get('text_related'); |
|
304
|
|
|
$data['text_loading'] = $this->language->get('text_loading'); |
|
305
|
|
|
$data['text_benefits'] = $this->language->get('text_benefits'); |
|
306
|
|
|
$data['text_help_options'] = $this->language->get('text_help_options'); |
|
307
|
|
|
$data['text_all_linked_categories'] = $this->language->get('text_all_linked_categories'); |
|
308
|
|
|
$data['text_you_save'] = $this->language->get('text_you_save'); |
|
309
|
|
|
$data['text_description'] = $this->language->get('text_description'); |
|
310
|
|
|
$data['text_go_back'] = $this->language->get('text_go_back'); |
|
311
|
|
|
|
|
312
|
|
|
$data['entry_qty'] = $this->language->get('entry_qty'); |
|
313
|
|
|
$data['entry_name'] = $this->language->get('entry_name'); |
|
314
|
|
|
$data['entry_review'] = $this->language->get('entry_review'); |
|
315
|
|
|
$data['entry_good'] = $this->language->get('entry_good'); |
|
316
|
|
|
$data['entry_bad'] = $this->language->get('entry_bad'); |
|
317
|
|
|
|
|
318
|
|
|
$data['button_buy_it'] = $this->language->get('button_buy_it'); |
|
319
|
|
|
$data['button_upload'] = $this->language->get('button_upload'); |
|
320
|
|
|
$data['button_continue'] = $this->language->get('button_continue'); |
|
321
|
|
|
|
|
322
|
|
|
$this->load->model('catalog/review'); |
|
323
|
|
|
|
|
324
|
|
|
$data['tab_gen_information'] = $this->language->get('tab_gen_information'); |
|
325
|
|
|
$data['tab_attribute'] = $this->language->get('tab_attribute'); |
|
326
|
|
|
$data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); |
|
327
|
|
|
|
|
328
|
|
|
$data['product_id'] = (int) $this->request->get['product_id']; |
|
329
|
|
|
$data['manufacturer'] = $product_info['manufacturer']; |
|
330
|
|
|
|
|
331
|
|
|
// +++ category-in-the-product-page | All linked categories |
|
332
|
|
|
$data['categories'] = $categories; |
|
333
|
|
|
// +++ |
|
334
|
|
|
|
|
335
|
|
|
$data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); |
|
336
|
|
|
$data['model'] = $product_info['model']; |
|
337
|
|
|
$data['reward'] = $product_info['reward']; |
|
338
|
|
|
$data['points'] = $product_info['points']; |
|
339
|
|
|
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); |
|
340
|
|
|
$data['sticker'] = $this->getStickers($product_info['product_id']); |
|
341
|
|
|
|
|
342
|
|
|
if ($product_info['quantity'] <= 0) { |
|
343
|
|
|
$data['stock'] = $product_info['stock_status']; |
|
344
|
|
|
} elseif ($this->config->get('config_stock_display')) { |
|
345
|
|
|
$data['stock'] = $product_info['quantity']; |
|
346
|
|
|
} else { |
|
347
|
|
|
$data['stock'] = $this->language->get('text_instock'); |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
// image |
|
351
|
|
|
|
|
352
|
|
|
|
|
353
|
|
|
if ($product_info['image']) { |
|
354
|
|
|
$data['popup'] = '/public_html/assets/images/' . $product_info['image']; |
|
355
|
|
|
$data['thumb'] = '/public_html/assets/images/' . $product_info['image']; |
|
356
|
|
|
} else { |
|
357
|
|
|
$data['popup'] = '/public_html/assets/images/no_image.png'; |
|
358
|
|
|
$data['thumb'] = '/public_html/assets/images/no_image.png'; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
$data['images'] = array(); |
|
362
|
|
|
|
|
363
|
|
|
static $image_id = 0; |
|
364
|
|
|
|
|
365
|
|
|
$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); |
|
366
|
|
|
|
|
367
|
|
|
foreach ($results as $result) { |
|
368
|
|
|
$data['images'][] = array( |
|
369
|
|
|
'popup' => '/public_html/assets/images/' . $result['image'], |
|
370
|
|
|
'thumb' => '/public_html/assets/images/' . $result['image'], |
|
371
|
|
|
'image_id' => $image_id++ |
|
372
|
|
|
); |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { |
|
376
|
|
|
$data['price'] = $this->currency->format($product_info['price'], $this->session->data['currency']); |
|
377
|
|
|
} else { |
|
378
|
|
|
$data['price'] = false; |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
if ((float) $product_info['special']) { |
|
382
|
|
|
$data['special'] = $this->currency->format($product_info['special'], $this->session->data['currency']); |
|
383
|
|
|
} else { |
|
384
|
|
|
$data['special'] = false; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
if ((float) $product_info['special']) { |
|
388
|
|
|
$data['yousave_money'] = $this->currency->format(($product_info['price'] - $product_info['special']), $this->session->data['currency']); |
|
389
|
|
|
} else { |
|
390
|
|
|
$data['yousave_money'] = false; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
if ((float) $product_info['special']) { |
|
394
|
|
|
$data['yousave_percent'] = round(((($product_info['price'] - $product_info['special']) / $product_info['price']) * 100), 0); |
|
395
|
|
|
} else { |
|
396
|
|
|
$data['yousave_percent'] = false; |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
$discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); |
|
400
|
|
|
|
|
401
|
|
|
$data['discounts'] = array(); |
|
402
|
|
|
|
|
403
|
|
|
foreach ($discounts as $discount) { |
|
404
|
|
|
$data['discounts'][] = array( |
|
405
|
|
|
'quantity' => $discount['quantity'], |
|
406
|
|
|
'price' => $this->currency->format($discount['price'], $this->session->data['currency']) |
|
407
|
|
|
); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
// benefits |
|
411
|
|
|
$productbenefits = $this->model_catalog_product->getProductBenefitsbyProductId($product_info['product_id']); |
|
412
|
|
|
|
|
413
|
|
|
$data['benefits'] = array(); |
|
414
|
|
|
|
|
415
|
|
|
foreach ($productbenefits as $benefit) { |
|
416
|
|
|
if ($benefit['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $benefit['image'])) { |
|
417
|
|
|
$bimage = $benefit['image']; |
|
418
|
|
|
if ($benefit['type']) { |
|
419
|
|
|
$bimage = '/public_html/assets/images/' . $bimage; |
|
420
|
|
|
} else { |
|
421
|
|
|
$bimage = '/public_html/assets/images/' . $bimage; |
|
422
|
|
|
} |
|
423
|
|
|
} else { |
|
424
|
|
|
$bimage = '/public_html/assets/images/no_image.png'; |
|
425
|
|
|
} |
|
426
|
|
|
$data['benefits'][] = array( |
|
427
|
|
|
'benefit_id' => $benefit['benefit_id'], |
|
428
|
|
|
'name' => $benefit['name'], |
|
429
|
|
|
'description' => strip_tags(html_entity_decode($benefit['description'])), |
|
430
|
|
|
'thumb' => $bimage, |
|
431
|
|
|
'link' => $benefit['link'], |
|
432
|
|
|
'type' => $benefit['type'] |
|
433
|
|
|
//'sort_order' => $benefit['sort_order'] |
|
434
|
|
|
); |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
// options |
|
438
|
|
|
$data['options'] = array(); |
|
439
|
|
|
|
|
440
|
|
|
foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { |
|
441
|
|
|
$product_option_value_data = array(); |
|
442
|
|
|
|
|
443
|
|
|
foreach ($option['product_option_value'] as $option_value) { |
|
444
|
|
|
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { |
|
445
|
|
|
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float) $option_value['price']) { |
|
|
|
|
|
|
446
|
|
|
$price = $this->currency->format($option_value['price'], $this->session->data['currency']); |
|
447
|
|
|
} else { |
|
448
|
|
|
$price = false; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
$product_option_value_data[] = array( |
|
452
|
|
|
'product_option_value_id' => $option_value['product_option_value_id'], |
|
453
|
|
|
'option_value_id' => $option_value['option_value_id'], |
|
454
|
|
|
'name' => $option_value['name'], |
|
455
|
|
|
'image' => '/public_html/assets/images/' . $option_value['image'], |
|
456
|
|
|
'price' => $price, |
|
457
|
|
|
'price_prefix' => $option_value['price_prefix'] |
|
458
|
|
|
); |
|
459
|
|
|
} |
|
460
|
|
|
} |
|
461
|
|
|
|
|
462
|
|
|
$data['options'][] = array( |
|
463
|
|
|
'product_option_id' => $option['product_option_id'], |
|
464
|
|
|
'product_option_value' => $product_option_value_data, |
|
465
|
|
|
'option_id' => $option['option_id'], |
|
466
|
|
|
'name' => $option['name'], |
|
467
|
|
|
'type' => $option['type'], |
|
468
|
|
|
'value' => $option['value'], |
|
469
|
|
|
'required' => $option['required'] |
|
470
|
|
|
); |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
// minimum |
|
474
|
|
|
if ($product_info['minimum']) { |
|
475
|
|
|
$data['minimum'] = $product_info['minimum']; |
|
476
|
|
|
} else { |
|
477
|
|
|
$data['minimum'] = 1; |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
// reviews |
|
481
|
|
|
$data['review_status'] = $this->config->get('config_review_status'); |
|
482
|
|
|
|
|
483
|
|
|
if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { |
|
484
|
|
|
$data['review_guest'] = true; |
|
485
|
|
|
} else { |
|
486
|
|
|
$data['review_guest'] = false; |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
if ($this->customer->isLogged()) { |
|
490
|
|
|
$data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); |
|
491
|
|
|
} else { |
|
492
|
|
|
$data['customer_name'] = ''; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
$data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']); |
|
496
|
|
|
|
|
497
|
|
|
$data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); |
|
498
|
|
|
|
|
499
|
|
|
$data['products'] = array(); |
|
500
|
|
|
|
|
501
|
|
|
$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); |
|
502
|
|
|
|
|
503
|
|
|
foreach ($results as $result) { |
|
504
|
|
|
if ($result['image']) { |
|
505
|
|
|
$image = '/public_html/assets/images/' . $result['image']; |
|
506
|
|
|
} else { |
|
507
|
|
|
$image = '/public_html/assets/images/no_image.png'; |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { |
|
511
|
|
|
$price = $this->currency->format($result['price'], $this->session->data['currency']); |
|
512
|
|
|
} else { |
|
513
|
|
|
$price = false; |
|
514
|
|
|
} |
|
515
|
|
|
|
|
516
|
|
|
if ((float) $result['special']) { |
|
517
|
|
|
$special = $this->currency->format($result['special'], $this->session->data['currency']); |
|
518
|
|
|
} else { |
|
519
|
|
|
$special = false; |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
if ((float) $result['special']) { |
|
523
|
|
|
$yousave_percent = round(((($result['price'] - $result['special']) / $result['price']) * 100), 0); |
|
524
|
|
|
} else { |
|
525
|
|
|
$yousave_percent = false; |
|
526
|
|
|
} |
|
527
|
|
|
|
|
528
|
|
|
// benefits |
|
529
|
|
|
$productbenefits = $this->model_catalog_product->getProductBenefitsbyProductId($result['product_id']); |
|
530
|
|
|
|
|
531
|
|
|
$benefits = array(); |
|
532
|
|
|
|
|
533
|
|
|
foreach ($productbenefits as $benefit) { |
|
534
|
|
|
if ($benefit['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $benefit['image'])) { |
|
535
|
|
|
$bimage = $benefit['image']; |
|
536
|
|
|
if ($benefit['type']) { |
|
537
|
|
|
$bimage = '/public_html/assets/images/' . $bimage; |
|
538
|
|
|
} else { |
|
539
|
|
|
$bimage = '/public_html/assets/images/' . $bimage; |
|
540
|
|
|
} |
|
541
|
|
|
} else { |
|
542
|
|
|
$bimage = '/public_html/assets/images/no_image.png'; |
|
543
|
|
|
} |
|
544
|
|
|
$benefits[] = array( |
|
545
|
|
|
'benefit_id' => $benefit['benefit_id'], |
|
546
|
|
|
'name' => $benefit['name'], |
|
547
|
|
|
'description' => strip_tags(html_entity_decode($benefit['description'])), |
|
548
|
|
|
'thumb' => $bimage, |
|
549
|
|
|
'link' => $benefit['link'], |
|
550
|
|
|
'type' => $benefit['type'] |
|
551
|
|
|
); |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
// stickers |
|
555
|
|
|
$stickers = $this->getStickers($result['product_id']); |
|
556
|
|
|
|
|
557
|
|
|
$data['products'][] = array( |
|
558
|
|
|
'product_id' => $result['product_id'], |
|
559
|
|
|
'thumb' => $image, |
|
560
|
|
|
'name' => $result['name'], |
|
561
|
|
|
'description' => \voku\helper\UTF8::substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', |
|
|
|
|
|
|
562
|
|
|
'price' => $price, |
|
563
|
|
|
'special' => $special, |
|
564
|
|
|
'yousave_percent' => $yousave_percent, |
|
565
|
|
|
'sticker' => $stickers, |
|
566
|
|
|
'benefits' => $benefits, |
|
567
|
|
|
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, |
|
568
|
|
|
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) |
|
569
|
|
|
); |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
// tags |
|
573
|
|
|
$data['tags'] = array(); |
|
574
|
|
|
|
|
575
|
|
|
if ($product_info['tag']) { |
|
576
|
|
|
$tags = explode(',', $product_info['tag']); |
|
577
|
|
|
|
|
578
|
|
|
foreach ($tags as $tag) { |
|
579
|
|
|
$data['tags'][] = array( |
|
580
|
|
|
'tag' => trim($tag), |
|
581
|
|
|
'href' => $this->url->link('product/search', 'tag=' . trim($tag)) |
|
582
|
|
|
); |
|
583
|
|
|
} |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
// update viewed |
|
587
|
|
|
$this->model_catalog_product->updateViewed($this->request->get['product_id']); |
|
588
|
|
|
|
|
589
|
|
|
// layout |
|
590
|
|
|
$data['content_top'] = $this->load->controller('common/content_top'); |
|
591
|
|
|
$data['content_bottom'] = $this->load->controller('common/content_bottom'); |
|
592
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
|
593
|
|
|
$data['header'] = $this->load->controller('common/header'); |
|
594
|
|
|
|
|
595
|
|
|
// tabs |
|
596
|
|
|
$data['product_tabs'] = array(); |
|
597
|
|
|
|
|
598
|
|
|
$tabresults = $this->model_catalog_product->getproducttab($this->request->get['product_id']); |
|
599
|
|
|
|
|
600
|
|
|
foreach ($tabresults as $result) { |
|
601
|
|
|
$data['product_tabs'][] = array( |
|
602
|
|
|
'product_tab_id' => $result['product_tab_id'], |
|
603
|
|
|
'title' => $result['heading'], |
|
604
|
|
|
'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), |
|
605
|
|
|
); |
|
606
|
|
|
} |
|
607
|
|
|
|
|
608
|
|
|
$this->response->setOutput($this->load->view('product/product', $data)); |
|
609
|
|
|
} else { |
|
610
|
|
|
$url = ''; |
|
611
|
|
|
|
|
612
|
|
|
if (isset($this->request->get['path'])) { |
|
613
|
|
|
$url .= '&path=' . $this->request->get['path']; |
|
614
|
|
|
} |
|
615
|
|
|
|
|
616
|
|
|
if (isset($this->request->get['filter'])) { |
|
617
|
|
|
$url .= '&filter=' . $this->request->get['filter']; |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
if (isset($this->request->get['manufacturer_id'])) { |
|
621
|
|
|
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; |
|
622
|
|
|
} |
|
623
|
|
|
|
|
624
|
|
|
if (isset($this->request->get['search'])) { |
|
625
|
|
|
$url .= '&search=' . $this->request->get['search']; |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
|
|
if (isset($this->request->get['tag'])) { |
|
629
|
|
|
$url .= '&tag=' . $this->request->get['tag']; |
|
630
|
|
|
} |
|
631
|
|
|
|
|
632
|
|
|
if (isset($this->request->get['description'])) { |
|
633
|
|
|
$url .= '&description=' . $this->request->get['description']; |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
if (isset($this->request->get['category_id'])) { |
|
637
|
|
|
$url .= '&category_id=' . $this->request->get['category_id']; |
|
638
|
|
|
} |
|
639
|
|
|
|
|
640
|
|
|
if (isset($this->request->get['sub_category'])) { |
|
641
|
|
|
$url .= '&sub_category=' . $this->request->get['sub_category']; |
|
642
|
|
|
} |
|
643
|
|
|
|
|
644
|
|
|
if (isset($this->request->get['sort'])) { |
|
645
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
|
646
|
|
|
} |
|
647
|
|
|
|
|
648
|
|
|
if (isset($this->request->get['order'])) { |
|
649
|
|
|
$url .= '&order=' . $this->request->get['order']; |
|
650
|
|
|
} |
|
651
|
|
|
|
|
652
|
|
|
if (isset($this->request->get['page'])) { |
|
653
|
|
|
$url .= '&page=' . $this->request->get['page']; |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
if (isset($this->request->get['limit'])) { |
|
657
|
|
|
$url .= '&limit=' . $this->request->get['limit']; |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
$data['breadcrumbs'][] = array( |
|
661
|
|
|
'text' => $this->language->get('text_error'), |
|
662
|
|
|
'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) |
|
663
|
|
|
); |
|
664
|
|
|
|
|
665
|
|
|
$this->document->setTitle($this->language->get('text_error')); |
|
666
|
|
|
|
|
667
|
|
|
$data['heading_title'] = $this->language->get('text_error'); |
|
668
|
|
|
|
|
669
|
|
|
$data['text_error'] = $this->language->get('text_error'); |
|
670
|
|
|
$data['text_go_back'] = $this->language->get('text_go_back'); |
|
671
|
|
|
$data['text_get_back'] = $this->language->get('text_get_back'); |
|
672
|
|
|
|
|
673
|
|
|
$data['button_continue'] = $this->language->get('button_continue'); |
|
674
|
|
|
|
|
675
|
|
|
$data['continue'] = $this->url->link('common/home'); |
|
676
|
|
|
|
|
677
|
|
|
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); |
|
678
|
|
|
|
|
679
|
|
|
$data['content_top'] = $this->load->controller('common/content_top'); |
|
680
|
|
|
$data['content_bottom'] = $this->load->controller('common/content_bottom'); |
|
681
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
|
682
|
|
|
$data['header'] = $this->load->controller('common/header'); |
|
683
|
|
|
|
|
684
|
|
|
$this->response->setOutput($this->load->view('error/not_found', $data)); |
|
685
|
|
|
} |
|
686
|
|
|
} |
|
687
|
|
|
|
|
688
|
|
|
public function review() |
|
689
|
|
|
{ |
|
690
|
|
|
$this->load->language('product/product'); |
|
691
|
|
|
|
|
692
|
|
|
$this->load->model('catalog/review'); |
|
693
|
|
|
|
|
694
|
|
|
$data['text_no_reviews'] = $this->language->get('text_no_reviews'); |
|
|
|
|
|
|
695
|
|
|
|
|
696
|
|
|
if (isset($this->request->get['page'])) { |
|
697
|
|
|
$page = $this->request->get['page']; |
|
698
|
|
|
} else { |
|
699
|
|
|
$page = 1; |
|
700
|
|
|
} |
|
701
|
|
|
|
|
702
|
|
|
$data['reviews'] = array(); |
|
703
|
|
|
|
|
704
|
|
|
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); |
|
705
|
|
|
|
|
706
|
|
|
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); |
|
707
|
|
|
|
|
708
|
|
|
foreach ($results as $result) { |
|
709
|
|
|
$data['reviews'][] = array( |
|
710
|
|
|
'author' => $result['author'], |
|
711
|
|
|
'text' => nl2br($result['text']), |
|
712
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) |
|
713
|
|
|
); |
|
714
|
|
|
} |
|
715
|
|
|
|
|
716
|
|
|
$pagination = new \Divine\Engine\Library\Pagination(); |
|
717
|
|
|
$pagination->total = $review_total; |
|
718
|
|
|
$pagination->page = $page; |
|
719
|
|
|
$pagination->limit = 5; |
|
720
|
|
|
$pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); |
|
721
|
|
|
|
|
722
|
|
|
$data['pagination'] = $pagination->render(); |
|
723
|
|
|
|
|
724
|
|
|
$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); |
|
725
|
|
|
|
|
726
|
|
|
$this->response->setOutput($this->load->view('product/review', $data)); |
|
727
|
|
|
} |
|
728
|
|
|
|
|
729
|
|
|
public function write() |
|
730
|
|
|
{ |
|
731
|
|
|
$this->load->language('product/product'); |
|
732
|
|
|
|
|
733
|
|
|
$json = array(); |
|
734
|
|
|
|
|
735
|
|
|
if ($this->request->server['REQUEST_METHOD'] == 'POST') { |
|
736
|
|
|
if ((\voku\helper\UTF8::strlen($this->request->post['name']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['name']) > 25)) { |
|
737
|
|
|
$json['error'] = $this->language->get('error_name'); |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
if ((\voku\helper\UTF8::strlen($this->request->post['text']) < 25) || (\voku\helper\UTF8::strlen($this->request->post['text']) > 1000)) { |
|
741
|
|
|
$json['error'] = $this->language->get('error_text'); |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
if (!isset($json['error'])) { |
|
745
|
|
|
$this->load->model('catalog/review'); |
|
746
|
|
|
|
|
747
|
|
|
$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); |
|
748
|
|
|
|
|
749
|
|
|
$json['success'] = $this->language->get('text_success'); |
|
750
|
|
|
} |
|
751
|
|
|
} |
|
752
|
|
|
|
|
753
|
|
|
$this->response->addHeader('Content-Type: application/json'); |
|
754
|
|
|
$this->response->setOutput(json_encode($json)); |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
private function getStickers($product_id) |
|
758
|
|
|
{ |
|
759
|
|
|
$stickers = $this->model_catalog_product->getProductStickerbyProductId($product_id); |
|
760
|
|
|
|
|
761
|
|
|
if (!$stickers) { |
|
762
|
|
|
return; |
|
763
|
|
|
} |
|
764
|
|
|
|
|
765
|
|
|
$data['stickers'] = array(); |
|
|
|
|
|
|
766
|
|
|
|
|
767
|
|
|
foreach ($stickers as $sticker) { |
|
768
|
|
|
$data['stickers'][] = array( |
|
769
|
|
|
'position' => $sticker['position'], |
|
770
|
|
|
'image' => '/public_html/assets/images/' . $sticker['image'] |
|
771
|
|
|
); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
return $this->load->view('product/stickers', $data); |
|
775
|
|
|
} |
|
776
|
|
|
} |
|
777
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.