Total Complexity | 374 |
Total Lines | 1938 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like ControllerCatalogProduct often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ControllerCatalogProduct, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
23 | class ControllerCatalogProduct extends \Divine\Engine\Core\Controller |
||
|
|||
24 | { |
||
25 | private $error = array(); |
||
26 | |||
27 | public function index() |
||
28 | { |
||
29 | $this->load->language('catalog/product'); |
||
30 | |||
31 | $this->document->setTitle($this->language->get('heading_title')); |
||
32 | |||
33 | $this->load->model('catalog/product'); |
||
34 | |||
35 | $this->getList(); |
||
36 | } |
||
37 | |||
38 | public function add() |
||
39 | { |
||
40 | $this->load->language('catalog/product'); |
||
41 | |||
42 | $this->document->setTitle($this->language->get('heading_title')); |
||
43 | |||
44 | $this->load->model('catalog/product'); |
||
45 | |||
46 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
47 | $this->model_catalog_product->addProduct($this->request->post); |
||
48 | |||
49 | $this->session->data['success'] = $this->language->get('text_success'); |
||
50 | |||
51 | $url = ''; |
||
52 | |||
53 | if (isset($this->request->get['filter_name'])) { |
||
54 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
55 | } |
||
56 | |||
57 | if (isset($this->request->get['filter_model'])) { |
||
58 | $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8')); |
||
59 | } |
||
60 | |||
61 | if (isset($this->request->get['filter_price'])) { |
||
62 | $url .= '&filter_price=' . $this->request->get['filter_price']; |
||
63 | } |
||
64 | |||
65 | if (isset($this->request->get['filter_price_min'])) { |
||
66 | $url .= '&filter_price_min=' . $this->request->get['filter_price_min']; |
||
67 | } |
||
68 | |||
69 | if (isset($this->request->get['filter_price_max'])) { |
||
70 | $url .= '&filter_price_max=' . $this->request->get['filter_price_max']; |
||
71 | } |
||
72 | |||
73 | if (isset($this->request->get['filter_quantity'])) { |
||
74 | $url .= '&filter_quantity=' . $this->request->get['filter_quantity']; |
||
75 | } |
||
76 | |||
77 | if (isset($this->request->get['filter_quantity_min'])) { |
||
78 | $url .= '&filter_quantity_min=' . $this->request->get['filter_quantity_min']; |
||
79 | } |
||
80 | |||
81 | if (isset($this->request->get['filter_quantity_max'])) { |
||
82 | $url .= '&filter_quantity_max=' . $this->request->get['filter_quantity_max']; |
||
83 | } |
||
84 | |||
85 | if (isset($this->request->get['filter_status'])) { |
||
86 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
87 | } |
||
88 | |||
89 | if (isset($this->request->get['filter_category'])) { |
||
90 | $url .= '&filter_category=' . $this->request->get['filter_category']; |
||
91 | if (isset($this->request->get['filter_sub_category'])) { |
||
92 | $url .= '&filter_sub_category'; |
||
93 | } |
||
94 | } |
||
95 | |||
96 | if (isset($this->request->get['filter_manufacturer'])) { |
||
97 | $url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer']; |
||
98 | } |
||
99 | |||
100 | if (isset($this->request->get['filter_noindex'])) { |
||
101 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||
102 | } |
||
103 | |||
104 | if (isset($this->request->get['sort'])) { |
||
105 | $url .= '&sort=' . $this->request->get['sort']; |
||
106 | } |
||
107 | |||
108 | if (isset($this->request->get['order'])) { |
||
109 | $url .= '&order=' . $this->request->get['order']; |
||
110 | } |
||
111 | |||
112 | if (isset($this->request->get['page'])) { |
||
113 | $url .= '&page=' . $this->request->get['page']; |
||
114 | } |
||
115 | |||
116 | $this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true)); |
||
117 | } |
||
118 | |||
119 | $this->getForm(); |
||
120 | } |
||
121 | |||
122 | public function edit() |
||
123 | { |
||
124 | $this->load->language('catalog/product'); |
||
125 | |||
126 | $this->document->setTitle($this->language->get('heading_title')); |
||
127 | |||
128 | $this->load->model('catalog/product'); |
||
129 | |||
130 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
131 | $this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post); |
||
132 | |||
133 | $this->session->data['success'] = $this->language->get('text_success'); |
||
134 | |||
135 | $url = ''; |
||
136 | |||
137 | if (isset($this->request->get['filter_name'])) { |
||
138 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
139 | } |
||
140 | |||
141 | if (isset($this->request->get['filter_model'])) { |
||
142 | $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8')); |
||
143 | } |
||
144 | |||
145 | if (isset($this->request->get['filter_price'])) { |
||
146 | $url .= '&filter_price=' . $this->request->get['filter_price']; |
||
147 | } |
||
148 | |||
149 | if (isset($this->request->get['filter_price_min'])) { |
||
150 | $url .= '&filter_price_min=' . $this->request->get['filter_price_min']; |
||
151 | } |
||
152 | |||
153 | if (isset($this->request->get['filter_price_max'])) { |
||
154 | $url .= '&filter_price_max=' . $this->request->get['filter_price_max']; |
||
155 | } |
||
156 | |||
157 | if (isset($this->request->get['filter_quantity'])) { |
||
158 | $url .= '&filter_quantity=' . $this->request->get['filter_quantity']; |
||
159 | } |
||
160 | |||
161 | if (isset($this->request->get['filter_quantity_min'])) { |
||
162 | $url .= '&filter_quantity_min=' . $this->request->get['filter_quantity_min']; |
||
163 | } |
||
164 | |||
165 | if (isset($this->request->get['filter_quantity_max'])) { |
||
166 | $url .= '&filter_quantity_max=' . $this->request->get['filter_quantity_max']; |
||
167 | } |
||
168 | |||
169 | if (isset($this->request->get['filter_status'])) { |
||
170 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
171 | } |
||
172 | |||
173 | if (isset($this->request->get['filter_category'])) { |
||
174 | $url .= '&filter_category=' . $this->request->get['filter_category']; |
||
175 | if (isset($this->request->get['filter_sub_category'])) { |
||
176 | $url .= '&filter_sub_category'; |
||
177 | } |
||
178 | } |
||
179 | |||
180 | if (isset($this->request->get['filter_manufacturer'])) { |
||
181 | $url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer']; |
||
182 | } |
||
183 | |||
184 | if (isset($this->request->get['filter_noindex'])) { |
||
185 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||
186 | } |
||
187 | |||
188 | if (isset($this->request->get['sort'])) { |
||
189 | $url .= '&sort=' . $this->request->get['sort']; |
||
190 | } |
||
191 | |||
192 | if (isset($this->request->get['order'])) { |
||
193 | $url .= '&order=' . $this->request->get['order']; |
||
194 | } |
||
195 | |||
196 | if (isset($this->request->get['page'])) { |
||
197 | $url .= '&page=' . $this->request->get['page']; |
||
198 | } |
||
199 | |||
200 | $this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true)); |
||
201 | } |
||
202 | |||
203 | $this->getForm(); |
||
204 | } |
||
205 | |||
206 | public function delete() |
||
207 | { |
||
208 | $this->load->language('catalog/product'); |
||
209 | |||
210 | $this->document->setTitle($this->language->get('heading_title')); |
||
211 | |||
212 | $this->load->model('catalog/product'); |
||
213 | |||
214 | if (isset($this->request->post['selected']) && $this->validateDelete()) { |
||
215 | foreach ($this->request->post['selected'] as $product_id) { |
||
216 | $this->model_catalog_product->deleteProduct($product_id); |
||
217 | } |
||
218 | |||
219 | $this->session->data['success'] = $this->language->get('text_success'); |
||
220 | |||
221 | $url = ''; |
||
222 | |||
223 | if (isset($this->request->get['filter_name'])) { |
||
224 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
225 | } |
||
226 | |||
227 | if (isset($this->request->get['filter_model'])) { |
||
228 | $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8')); |
||
229 | } |
||
230 | |||
231 | if (isset($this->request->get['filter_price'])) { |
||
232 | $url .= '&filter_price=' . $this->request->get['filter_price']; |
||
233 | } |
||
234 | |||
235 | if (isset($this->request->get['filter_price_min'])) { |
||
236 | $url .= '&filter_price_min=' . $this->request->get['filter_price_min']; |
||
237 | } |
||
238 | |||
239 | if (isset($this->request->get['filter_price_max'])) { |
||
240 | $url .= '&filter_price_max=' . $this->request->get['filter_price_max']; |
||
241 | } |
||
242 | |||
243 | if (isset($this->request->get['filter_quantity'])) { |
||
244 | $url .= '&filter_quantity=' . $this->request->get['filter_quantity']; |
||
245 | } |
||
246 | |||
247 | if (isset($this->request->get['filter_quantity_min'])) { |
||
248 | $url .= '&filter_quantity_min=' . $this->request->get['filter_quantity_min']; |
||
249 | } |
||
250 | |||
251 | if (isset($this->request->get['filter_quantity_max'])) { |
||
252 | $url .= '&filter_quantity_max=' . $this->request->get['filter_quantity_max']; |
||
253 | } |
||
254 | |||
255 | if (isset($this->request->get['filter_status'])) { |
||
256 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
257 | } |
||
258 | |||
259 | if (isset($this->request->get['filter_category'])) { |
||
260 | $url .= '&filter_category=' . $this->request->get['filter_category']; |
||
261 | if (isset($this->request->get['filter_sub_category'])) { |
||
262 | $url .= '&filter_sub_category'; |
||
263 | } |
||
264 | } |
||
265 | |||
266 | if (isset($this->request->get['filter_manufacturer'])) { |
||
267 | $url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer']; |
||
268 | } |
||
269 | |||
270 | if (isset($this->request->get['filter_noindex'])) { |
||
271 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||
272 | } |
||
273 | |||
274 | if (isset($this->request->get['sort'])) { |
||
275 | $url .= '&sort=' . $this->request->get['sort']; |
||
276 | } |
||
277 | |||
278 | if (isset($this->request->get['order'])) { |
||
279 | $url .= '&order=' . $this->request->get['order']; |
||
280 | } |
||
281 | |||
282 | if (isset($this->request->get['page'])) { |
||
283 | $url .= '&page=' . $this->request->get['page']; |
||
284 | } |
||
285 | |||
286 | $this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true)); |
||
287 | } |
||
288 | |||
289 | $this->getList(); |
||
290 | } |
||
291 | |||
292 | public function copy() |
||
376 | } |
||
377 | |||
378 | protected function getList() |
||
913 | } |
||
914 | |||
915 | protected function getForm() |
||
916 | { |
||
917 | $data['heading_title'] = $this->language->get('heading_title'); |
||
918 | |||
919 | $data['text_form'] = !isset($this->request->get['product_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
920 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
921 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
922 | $data['text_none'] = $this->language->get('text_none'); |
||
923 | $data['text_yes'] = $this->language->get('text_yes'); |
||
924 | $data['text_no'] = $this->language->get('text_no'); |
||
925 | $data['text_plus'] = $this->language->get('text_plus'); |
||
926 | $data['text_minus'] = $this->language->get('text_minus'); |
||
927 | $data['text_default'] = $this->language->get('text_default'); |
||
928 | $data['text_option'] = $this->language->get('text_option'); |
||
929 | $data['text_option_value'] = $this->language->get('text_option_value'); |
||
930 | $data['text_select'] = $this->language->get('text_select'); |
||
931 | $data['text_percent'] = $this->language->get('text_percent'); |
||
932 | $data['text_amount'] = $this->language->get('text_amount'); |
||
933 | $data['text_add'] = $this->language->get('text_add'); |
||
934 | |||
935 | $data['entry_name'] = $this->language->get('entry_name'); |
||
936 | $data['entry_description'] = $this->language->get('entry_description'); |
||
937 | $data['entry_description_mini'] = $this->language->get('entry_description_mini'); |
||
938 | $data['entry_meta_title'] = $this->language->get('entry_meta_title'); |
||
939 | $data['entry_meta_h1'] = $this->language->get('entry_meta_h1'); |
||
940 | $data['entry_meta_description'] = $this->language->get('entry_meta_description'); |
||
941 | $data['entry_keyword'] = $this->language->get('entry_keyword'); |
||
942 | $data['entry_model'] = $this->language->get('entry_model'); |
||
943 | $data['entry_sku'] = $this->language->get('entry_sku'); |
||
944 | $data['entry_upc'] = $this->language->get('entry_upc'); |
||
945 | $data['entry_ean'] = $this->language->get('entry_ean'); |
||
946 | $data['entry_jan'] = $this->language->get('entry_jan'); |
||
947 | $data['entry_isbn'] = $this->language->get('entry_isbn'); |
||
948 | $data['entry_mpn'] = $this->language->get('entry_mpn'); |
||
949 | $data['entry_location'] = $this->language->get('entry_location'); |
||
950 | $data['entry_minimum'] = $this->language->get('entry_minimum'); |
||
951 | $data['entry_shipping'] = $this->language->get('entry_shipping'); |
||
952 | $data['entry_quantity'] = $this->language->get('entry_quantity'); |
||
953 | $data['entry_stock_status'] = $this->language->get('entry_stock_status'); |
||
954 | $data['entry_price'] = $this->language->get('entry_price'); |
||
955 | $data['entry_points'] = $this->language->get('entry_points'); |
||
956 | $data['entry_option_points'] = $this->language->get('entry_option_points'); |
||
957 | $data['entry_subtract'] = $this->language->get('entry_subtract'); |
||
958 | $data['entry_dimension'] = $this->language->get('entry_dimension'); |
||
959 | $data['entry_width'] = $this->language->get('entry_width'); |
||
960 | $data['entry_height'] = $this->language->get('entry_height'); |
||
961 | $data['entry_image'] = $this->language->get('entry_image'); |
||
962 | $data['entry_additional_image'] = $this->language->get('entry_additional_image'); |
||
963 | $data['entry_manufacturer'] = $this->language->get('entry_manufacturer'); |
||
964 | $data['entry_download'] = $this->language->get('entry_download'); |
||
965 | $data['entry_category'] = $this->language->get('entry_category'); |
||
966 | $data['entry_main_category'] = $this->language->get('entry_main_category'); |
||
967 | $data['entry_filter'] = $this->language->get('entry_filter'); |
||
968 | $data['entry_related'] = $this->language->get('entry_related'); |
||
969 | $data['entry_related_article'] = $this->language->get('entry_related_article'); |
||
970 | $data['entry_attribute'] = $this->language->get('entry_attribute'); |
||
971 | $data['entry_text'] = $this->language->get('entry_text'); |
||
972 | $data['entry_option'] = $this->language->get('entry_option'); |
||
973 | $data['entry_option_value'] = $this->language->get('entry_option_value'); |
||
974 | $data['entry_required'] = $this->language->get('entry_required'); |
||
975 | $data['entry_sort_order'] = $this->language->get('entry_sort_order'); |
||
976 | $data['entry_status'] = $this->language->get('entry_status'); |
||
977 | $data['entry_noindex'] = $this->language->get('entry_noindex'); |
||
978 | $data['entry_date_start'] = $this->language->get('entry_date_start'); |
||
979 | $data['entry_date_end'] = $this->language->get('entry_date_end'); |
||
980 | $data['entry_priority'] = $this->language->get('entry_priority'); |
||
981 | $data['entry_tag'] = $this->language->get('entry_tag'); |
||
982 | $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
||
983 | $data['entry_reward'] = $this->language->get('entry_reward'); |
||
984 | $data['entry_layout'] = $this->language->get('entry_layout'); |
||
985 | $data['entry_heading'] = $this->language->get('entry_heading'); |
||
986 | |||
987 | $data['help_keyword'] = $this->language->get('help_keyword'); |
||
988 | $data['help_sku'] = $this->language->get('help_sku'); |
||
989 | $data['help_upc'] = $this->language->get('help_upc'); |
||
990 | $data['help_ean'] = $this->language->get('help_ean'); |
||
991 | $data['help_jan'] = $this->language->get('help_jan'); |
||
992 | $data['help_isbn'] = $this->language->get('help_isbn'); |
||
993 | $data['help_mpn'] = $this->language->get('help_mpn'); |
||
994 | $data['help_minimum'] = $this->language->get('help_minimum'); |
||
995 | $data['help_manufacturer'] = $this->language->get('help_manufacturer'); |
||
996 | $data['help_stock_status'] = $this->language->get('help_stock_status'); |
||
997 | $data['help_points'] = $this->language->get('help_points'); |
||
998 | $data['help_category'] = $this->language->get('help_category'); |
||
999 | $data['help_filter'] = $this->language->get('help_filter'); |
||
1000 | $data['help_download'] = $this->language->get('help_download'); |
||
1001 | $data['help_related'] = $this->language->get('help_related'); |
||
1002 | $data['help_tag'] = $this->language->get('help_tag'); |
||
1003 | $data['help_noindex'] = $this->language->get('help_noindex'); |
||
1004 | |||
1005 | $data['button_save'] = $this->language->get('button_save'); |
||
1006 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
1007 | $data['button_attribute_add'] = $this->language->get('button_attribute_add'); |
||
1008 | $data['button_option_add'] = $this->language->get('button_option_add'); |
||
1009 | $data['button_option_value_add'] = $this->language->get('button_option_value_add'); |
||
1010 | $data['button_discount_add'] = $this->language->get('button_discount_add'); |
||
1011 | $data['button_special_add'] = $this->language->get('button_special_add'); |
||
1012 | $data['button_image_add'] = $this->language->get('button_image_add'); |
||
1013 | $data['button_remove'] = $this->language->get('button_remove'); |
||
1014 | |||
1015 | $data['tab_general'] = $this->language->get('tab_general'); |
||
1016 | $data['tab_data'] = $this->language->get('tab_data'); |
||
1017 | $data['tab_attribute'] = $this->language->get('tab_attribute'); |
||
1018 | $data['tab_option'] = $this->language->get('tab_option'); |
||
1019 | $data['tab_discount'] = $this->language->get('tab_discount'); |
||
1020 | $data['tab_special'] = $this->language->get('tab_special'); |
||
1021 | $data['tab_image'] = $this->language->get('tab_image'); |
||
1022 | $data['tab_links'] = $this->language->get('tab_links'); |
||
1023 | $data['tab_reward'] = $this->language->get('tab_reward'); |
||
1024 | $data['tab_design'] = $this->language->get('tab_design'); |
||
1025 | $data['tab_openbay'] = $this->language->get('tab_openbay'); |
||
1026 | $data['tab_extra_tab'] = $this->language->get('tab_extra_tab'); |
||
1027 | $data['tab_module'] = $this->language->get('tab_module'); |
||
1028 | $data['text_corner0'] = $this->language->get('text_corner0'); |
||
1029 | $data['text_corner1'] = $this->language->get('text_corner1'); |
||
1030 | $data['text_corner2'] = $this->language->get('text_corner2'); |
||
1031 | $data['text_corner3'] = $this->language->get('text_corner3'); |
||
1032 | $data['entry_sticker'] = $this->language->get('entry_sticker'); |
||
1033 | $data['text_benefits'] = $this->language->get('text_benefits'); |
||
1034 | |||
1035 | if (isset($this->error['warning'])) { |
||
1036 | $data['error_warning'] = $this->error['warning']; |
||
1037 | } else { |
||
1038 | $data['error_warning'] = ''; |
||
1039 | } |
||
1040 | |||
1041 | if (isset($this->error['name'])) { |
||
1042 | $data['error_name'] = $this->error['name']; |
||
1043 | } else { |
||
1044 | $data['error_name'] = array(); |
||
1045 | } |
||
1046 | |||
1047 | if (isset($this->error['meta_title'])) { |
||
1048 | $data['error_meta_title'] = $this->error['meta_title']; |
||
1049 | } else { |
||
1050 | $data['error_meta_title'] = array(); |
||
1051 | } |
||
1052 | |||
1053 | if (isset($this->error['meta_h1'])) { |
||
1054 | $data['error_meta_h1'] = $this->error['meta_h1']; |
||
1055 | } else { |
||
1056 | $data['error_meta_h1'] = array(); |
||
1057 | } |
||
1058 | |||
1059 | if (isset($this->error['model'])) { |
||
1060 | $data['error_model'] = $this->error['model']; |
||
1061 | } else { |
||
1062 | $data['error_model'] = ''; |
||
1063 | } |
||
1064 | |||
1065 | if (isset($this->error['tab'])) { |
||
1066 | $data['error_tab'] = $this->error['tab']; |
||
1067 | } else { |
||
1068 | $data['error_tab'] = array(); |
||
1069 | } |
||
1070 | |||
1071 | if (isset($this->error['keyword'])) { |
||
1072 | $data['error_keyword'] = $this->error['keyword']; |
||
1073 | } else { |
||
1074 | $data['error_keyword'] = ''; |
||
1075 | } |
||
1076 | |||
1077 | $url = ''; |
||
1078 | |||
1079 | if (isset($this->request->get['filter_name'])) { |
||
1080 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||
1081 | } |
||
1082 | |||
1083 | if (isset($this->request->get['filter_model'])) { |
||
1084 | $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8')); |
||
1085 | } |
||
1086 | |||
1087 | if (isset($this->request->get['filter_price'])) { |
||
1088 | $url .= '&filter_price=' . $this->request->get['filter_price']; |
||
1089 | } |
||
1090 | |||
1091 | if (isset($this->request->get['filter_price_min'])) { |
||
1092 | $url .= '&filter_price_min=' . $this->request->get['filter_price_min']; |
||
1093 | } |
||
1094 | |||
1095 | if (isset($this->request->get['filter_price_max'])) { |
||
1096 | $url .= '&filter_price_max=' . $this->request->get['filter_price_max']; |
||
1097 | } |
||
1098 | |||
1099 | if (isset($this->request->get['filter_quantity'])) { |
||
1100 | $url .= '&filter_quantity=' . $this->request->get['filter_quantity']; |
||
1101 | } |
||
1102 | |||
1103 | if (isset($this->request->get['filter_quantity_min'])) { |
||
1104 | $url .= '&filter_quantity_min=' . $this->request->get['filter_quantity_min']; |
||
1105 | } |
||
1106 | |||
1107 | if (isset($this->request->get['filter_quantity_max'])) { |
||
1108 | $url .= '&filter_quantity_max=' . $this->request->get['filter_quantity_max']; |
||
1109 | } |
||
1110 | |||
1111 | if (isset($this->request->get['filter_status'])) { |
||
1112 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||
1113 | } |
||
1114 | |||
1115 | if (isset($this->request->get['filter_category'])) { |
||
1116 | $url .= '&filter_category=' . $this->request->get['filter_category']; |
||
1117 | if (isset($this->request->get['filter_sub_category'])) { |
||
1118 | $url .= '&filter_sub_category'; |
||
1119 | } |
||
1120 | } |
||
1121 | |||
1122 | if (isset($this->request->get['filter_manufacturer'])) { |
||
1123 | $url .= '&filter_manufacturer=' . $this->request->get['filter_manufacturer']; |
||
1124 | } |
||
1125 | |||
1126 | if (isset($this->request->get['filter_noindex'])) { |
||
1127 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||
1128 | } |
||
1129 | |||
1130 | if (isset($this->request->get['sort'])) { |
||
1131 | $url .= '&sort=' . $this->request->get['sort']; |
||
1132 | } |
||
1133 | |||
1134 | if (isset($this->request->get['order'])) { |
||
1135 | $url .= '&order=' . $this->request->get['order']; |
||
1136 | } |
||
1137 | |||
1138 | if (isset($this->request->get['page'])) { |
||
1139 | $url .= '&page=' . $this->request->get['page']; |
||
1140 | } |
||
1141 | |||
1142 | $data['breadcrumbs'] = array(); |
||
1143 | |||
1144 | $data['breadcrumbs'][] = array( |
||
1145 | 'text' => $this->language->get('text_home'), |
||
1146 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
1147 | ); |
||
1148 | |||
1149 | $data['breadcrumbs'][] = array( |
||
1150 | 'text' => $this->language->get('heading_title'), |
||
1151 | 'href' => $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true) |
||
1152 | ); |
||
1153 | |||
1154 | if (!isset($this->request->get['product_id'])) { |
||
1155 | $data['action'] = $this->url->link('catalog/product/add', 'token=' . $this->session->data['token'] . $url, true); |
||
1156 | } else { |
||
1157 | $data['action'] = $this->url->link('catalog/product/edit', 'token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'] . $url, true); |
||
1158 | } |
||
1159 | |||
1160 | $data['cancel'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true); |
||
1161 | |||
1162 | if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
1163 | $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']); |
||
1164 | } |
||
1165 | |||
1166 | $data['token'] = $this->session->data['token']; |
||
1167 | |||
1168 | $this->load->model('localisation/language'); |
||
1169 | |||
1170 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||
1171 | |||
1172 | if (isset($this->request->post['product_description'])) { |
||
1173 | $data['product_description'] = $this->request->post['product_description']; |
||
1174 | } elseif (isset($this->request->get['product_id'])) { |
||
1175 | $data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']); |
||
1176 | } else { |
||
1177 | $data['product_description'] = array(); |
||
1178 | } |
||
1179 | |||
1180 | $language_id = $this->config->get('config_language_id'); |
||
1181 | if (isset($data['product_description'][$language_id]['name'])) { |
||
1182 | $data['heading_title'] = $data['product_description'][$language_id]['name']; |
||
1183 | } |
||
1184 | |||
1185 | if (isset($this->request->post['model'])) { |
||
1186 | $data['model'] = $this->request->post['model']; |
||
1187 | } elseif (!empty($product_info)) { |
||
1188 | $data['model'] = $product_info['model']; |
||
1189 | } else { |
||
1190 | $data['model'] = ''; |
||
1191 | } |
||
1192 | |||
1193 | if (isset($this->request->post['sku'])) { |
||
1194 | $data['sku'] = $this->request->post['sku']; |
||
1195 | } elseif (!empty($product_info)) { |
||
1196 | $data['sku'] = $product_info['sku']; |
||
1197 | } else { |
||
1198 | $data['sku'] = ''; |
||
1199 | } |
||
1200 | |||
1201 | if (isset($this->request->post['upc'])) { |
||
1202 | $data['upc'] = $this->request->post['upc']; |
||
1203 | } elseif (!empty($product_info)) { |
||
1204 | $data['upc'] = $product_info['upc']; |
||
1205 | } else { |
||
1206 | $data['upc'] = ''; |
||
1207 | } |
||
1208 | |||
1209 | if (isset($this->request->post['ean'])) { |
||
1210 | $data['ean'] = $this->request->post['ean']; |
||
1211 | } elseif (!empty($product_info)) { |
||
1212 | $data['ean'] = $product_info['ean']; |
||
1213 | } else { |
||
1214 | $data['ean'] = ''; |
||
1215 | } |
||
1216 | |||
1217 | if (isset($this->request->post['jan'])) { |
||
1218 | $data['jan'] = $this->request->post['jan']; |
||
1219 | } elseif (!empty($product_info)) { |
||
1220 | $data['jan'] = $product_info['jan']; |
||
1221 | } else { |
||
1222 | $data['jan'] = ''; |
||
1223 | } |
||
1224 | |||
1225 | if (isset($this->request->post['isbn'])) { |
||
1226 | $data['isbn'] = $this->request->post['isbn']; |
||
1227 | } elseif (!empty($product_info)) { |
||
1228 | $data['isbn'] = $product_info['isbn']; |
||
1229 | } else { |
||
1230 | $data['isbn'] = ''; |
||
1231 | } |
||
1232 | |||
1233 | if (isset($this->request->post['mpn'])) { |
||
1234 | $data['mpn'] = $this->request->post['mpn']; |
||
1235 | } elseif (!empty($product_info)) { |
||
1236 | $data['mpn'] = $product_info['mpn']; |
||
1237 | } else { |
||
1238 | $data['mpn'] = ''; |
||
1239 | } |
||
1240 | |||
1241 | if (isset($this->request->post['location'])) { |
||
1242 | $data['location'] = $this->request->post['location']; |
||
1243 | } elseif (!empty($product_info)) { |
||
1244 | $data['location'] = $product_info['location']; |
||
1245 | } else { |
||
1246 | $data['location'] = ''; |
||
1247 | } |
||
1248 | |||
1249 | if (isset($this->request->post['keyword'])) { |
||
1250 | $data['keyword'] = $this->request->post['keyword']; |
||
1251 | } elseif (!empty($product_info)) { |
||
1252 | $data['keyword'] = $product_info['keyword']; |
||
1253 | } else { |
||
1254 | $data['keyword'] = ''; |
||
1255 | } |
||
1256 | |||
1257 | if (isset($this->request->post['shipping'])) { |
||
1258 | $data['shipping'] = $this->request->post['shipping']; |
||
1259 | } elseif (!empty($product_info)) { |
||
1260 | $data['shipping'] = $product_info['shipping']; |
||
1261 | } else { |
||
1262 | $data['shipping'] = 1; |
||
1263 | } |
||
1264 | |||
1265 | if (isset($this->request->post['price'])) { |
||
1266 | $data['price'] = $this->request->post['price']; |
||
1267 | } elseif (!empty($product_info)) { |
||
1268 | $data['price'] = $product_info['price']; |
||
1269 | } else { |
||
1270 | $data['price'] = ''; |
||
1271 | } |
||
1272 | |||
1273 | if (isset($this->request->post['quantity'])) { |
||
1274 | $data['quantity'] = $this->request->post['quantity']; |
||
1275 | } elseif (!empty($product_info)) { |
||
1276 | $data['quantity'] = $product_info['quantity']; |
||
1277 | } else { |
||
1278 | $data['quantity'] = 1; |
||
1279 | } |
||
1280 | |||
1281 | if (isset($this->request->post['minimum'])) { |
||
1282 | $data['minimum'] = $this->request->post['minimum']; |
||
1283 | } elseif (!empty($product_info)) { |
||
1284 | $data['minimum'] = $product_info['minimum']; |
||
1285 | } else { |
||
1286 | $data['minimum'] = 1; |
||
1287 | } |
||
1288 | |||
1289 | if (isset($this->request->post['subtract'])) { |
||
1290 | $data['subtract'] = $this->request->post['subtract']; |
||
1291 | } elseif (!empty($product_info)) { |
||
1292 | $data['subtract'] = $product_info['subtract']; |
||
1293 | } else { |
||
1294 | $data['subtract'] = 1; |
||
1295 | } |
||
1296 | |||
1297 | if (isset($this->request->post['sort_order'])) { |
||
1298 | $data['sort_order'] = $this->request->post['sort_order']; |
||
1299 | } elseif (!empty($product_info)) { |
||
1300 | $data['sort_order'] = $product_info['sort_order']; |
||
1301 | } else { |
||
1302 | $data['sort_order'] = 1; |
||
1303 | } |
||
1304 | |||
1305 | $this->load->model('localisation/stock_status'); |
||
1306 | |||
1307 | $data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses(); |
||
1308 | |||
1309 | if (isset($this->request->post['stock_status_id'])) { |
||
1310 | $data['stock_status_id'] = $this->request->post['stock_status_id']; |
||
1311 | } elseif (!empty($product_info)) { |
||
1312 | $data['stock_status_id'] = $product_info['stock_status_id']; |
||
1313 | } else { |
||
1314 | $data['stock_status_id'] = 0; |
||
1315 | } |
||
1316 | |||
1317 | if (isset($this->request->post['status'])) { |
||
1318 | $data['status'] = $this->request->post['status']; |
||
1319 | } elseif (!empty($product_info)) { |
||
1320 | $data['status'] = $product_info['status']; |
||
1321 | } else { |
||
1322 | $data['status'] = true; |
||
1323 | } |
||
1324 | |||
1325 | if (isset($this->request->post['noindex'])) { |
||
1326 | $data['noindex'] = $this->request->post['noindex']; |
||
1327 | } elseif (!empty($product_info)) { |
||
1328 | $data['noindex'] = $product_info['noindex']; |
||
1329 | } else { |
||
1330 | $data['noindex'] = 1; |
||
1331 | } |
||
1332 | |||
1333 | if (isset($this->request->post['width'])) { |
||
1334 | $data['width'] = $this->request->post['width']; |
||
1335 | } elseif (!empty($product_info)) { |
||
1336 | $data['width'] = $product_info['width']; |
||
1337 | } else { |
||
1338 | $data['width'] = ''; |
||
1339 | } |
||
1340 | |||
1341 | if (isset($this->request->post['height'])) { |
||
1342 | $data['height'] = $this->request->post['height']; |
||
1343 | } elseif (!empty($product_info)) { |
||
1344 | $data['height'] = $product_info['height']; |
||
1345 | } else { |
||
1346 | $data['height'] = ''; |
||
1347 | } |
||
1348 | |||
1349 | $this->load->model('catalog/manufacturer'); |
||
1350 | |||
1351 | if (isset($this->request->post['manufacturer_id'])) { |
||
1352 | $data['manufacturer_id'] = $this->request->post['manufacturer_id']; |
||
1353 | } elseif (!empty($product_info)) { |
||
1354 | $data['manufacturer_id'] = $product_info['manufacturer_id']; |
||
1355 | } else { |
||
1356 | $data['manufacturer_id'] = 0; |
||
1357 | } |
||
1358 | |||
1359 | if (isset($this->request->post['manufacturer'])) { |
||
1360 | $data['manufacturer'] = $this->request->post['manufacturer']; |
||
1361 | } elseif (!empty($product_info)) { |
||
1362 | $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']); |
||
1363 | |||
1364 | if ($manufacturer_info) { |
||
1365 | $data['manufacturer'] = $manufacturer_info['name']; |
||
1366 | } else { |
||
1367 | $data['manufacturer'] = ''; |
||
1368 | } |
||
1369 | } else { |
||
1370 | $data['manufacturer'] = ''; |
||
1371 | } |
||
1372 | |||
1373 | // Categories |
||
1374 | $this->load->model('catalog/category'); |
||
1375 | |||
1376 | $categories = $this->model_catalog_category->getAllCategories(); |
||
1377 | |||
1378 | $data['categories'] = $this->model_catalog_category->getCategories($categories); |
||
1379 | |||
1380 | if (isset($this->request->post['main_category_id'])) { |
||
1381 | $data['main_category_id'] = $this->request->post['main_category_id']; |
||
1382 | } elseif (isset($product_info)) { |
||
1383 | $data['main_category_id'] = $this->model_catalog_product->getProductMainCategoryId($this->request->get['product_id']); |
||
1384 | } else { |
||
1385 | $data['main_category_id'] = 0; |
||
1386 | } |
||
1387 | |||
1388 | if (isset($this->request->post['product_category'])) { |
||
1389 | $categories = $this->request->post['product_category']; |
||
1390 | } elseif (isset($this->request->get['product_id'])) { |
||
1391 | $categories = $this->model_catalog_product->getProductCategories($this->request->get['product_id']); |
||
1392 | } else { |
||
1393 | $categories = array(); |
||
1394 | } |
||
1395 | |||
1396 | $data['product_categories'] = array(); |
||
1397 | |||
1398 | foreach ($categories as $category_id) { |
||
1399 | $category_info = $this->model_catalog_category->getCategory($category_id); |
||
1400 | |||
1401 | if ($category_info) { |
||
1402 | $data['product_categories'][] = array( |
||
1403 | 'category_id' => $category_info['category_id'], |
||
1404 | 'name' => ($category_info['path']) ? $category_info['path'] . ' > ' . $category_info['name'] : $category_info['name'] |
||
1405 | ); |
||
1406 | } |
||
1407 | } |
||
1408 | |||
1409 | // Filters |
||
1410 | $this->load->model('catalog/filter'); |
||
1411 | |||
1412 | if (isset($this->request->post['product_filter'])) { |
||
1413 | $filters = $this->request->post['product_filter']; |
||
1414 | } elseif (isset($this->request->get['product_id'])) { |
||
1415 | $filters = $this->model_catalog_product->getProductFilters($this->request->get['product_id']); |
||
1416 | } else { |
||
1417 | $filters = array(); |
||
1418 | } |
||
1419 | |||
1420 | $data['product_filters'] = array(); |
||
1421 | |||
1422 | foreach ($filters as $filter_id) { |
||
1423 | $filter_info = $this->model_catalog_filter->getFilter($filter_id); |
||
1424 | |||
1425 | if ($filter_info) { |
||
1426 | $data['product_filters'][] = array( |
||
1427 | 'filter_id' => $filter_info['filter_id'], |
||
1428 | 'name' => $filter_info['group'] . ' > ' . $filter_info['name'] |
||
1429 | ); |
||
1430 | } |
||
1431 | } |
||
1432 | |||
1433 | // Attributes |
||
1434 | $this->load->model('catalog/attribute'); |
||
1435 | |||
1436 | if (isset($this->request->post['product_attribute'])) { |
||
1437 | $product_attributes = $this->request->post['product_attribute']; |
||
1438 | } elseif (isset($this->request->get['product_id'])) { |
||
1439 | $product_attributes = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); |
||
1440 | } else { |
||
1441 | $product_attributes = array(); |
||
1442 | } |
||
1443 | |||
1444 | $data['product_attributes'] = array(); |
||
1445 | |||
1446 | foreach ($product_attributes as $product_attribute) { |
||
1447 | $attribute_info = $this->model_catalog_attribute->getAttribute($product_attribute['attribute_id']); |
||
1448 | |||
1449 | if ($attribute_info) { |
||
1450 | $data['product_attributes'][] = array( |
||
1451 | 'attribute_id' => $product_attribute['attribute_id'], |
||
1452 | 'name' => $attribute_info['name'], |
||
1453 | 'product_attribute_description' => $product_attribute['product_attribute_description'] |
||
1454 | ); |
||
1455 | } |
||
1456 | } |
||
1457 | |||
1458 | // Options |
||
1459 | $this->load->model('catalog/option'); |
||
1460 | |||
1461 | if (isset($this->request->post['product_option'])) { |
||
1462 | $product_options = $this->request->post['product_option']; |
||
1463 | } elseif (isset($this->request->get['product_id'])) { |
||
1464 | $product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); |
||
1465 | } else { |
||
1466 | $product_options = array(); |
||
1467 | } |
||
1468 | |||
1469 | $data['product_options'] = array(); |
||
1470 | |||
1471 | foreach ($product_options as $product_option) { |
||
1472 | $product_option_value_data = array(); |
||
1473 | |||
1474 | if (isset($product_option['product_option_value'])) { |
||
1475 | foreach ($product_option['product_option_value'] as $product_option_value) { |
||
1476 | $product_option_value_data[] = array( |
||
1477 | 'product_option_value_id' => $product_option_value['product_option_value_id'], |
||
1478 | 'option_value_id' => $product_option_value['option_value_id'], |
||
1479 | 'quantity' => $product_option_value['quantity'], |
||
1480 | 'subtract' => $product_option_value['subtract'], |
||
1481 | 'price' => $product_option_value['price'], |
||
1482 | 'price_prefix' => $product_option_value['price_prefix'], |
||
1483 | 'points' => $product_option_value['points'], |
||
1484 | 'points_prefix' => $product_option_value['points_prefix'] |
||
1485 | ); |
||
1486 | } |
||
1487 | } |
||
1488 | |||
1489 | $data['product_options'][] = array( |
||
1490 | 'product_option_id' => $product_option['product_option_id'], |
||
1491 | 'product_option_value' => $product_option_value_data, |
||
1492 | 'option_id' => $product_option['option_id'], |
||
1493 | 'name' => $product_option['name'], |
||
1494 | 'type' => $product_option['type'], |
||
1495 | 'value' => isset($product_option['value']) ? $product_option['value'] : '', |
||
1496 | 'required' => $product_option['required'] |
||
1497 | ); |
||
1498 | } |
||
1499 | |||
1500 | $data['option_values'] = array(); |
||
1501 | |||
1502 | foreach ($data['product_options'] as $product_option) { |
||
1503 | if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') { |
||
1504 | if (!isset($data['option_values'][$product_option['option_id']])) { |
||
1505 | $data['option_values'][$product_option['option_id']] = $this->model_catalog_option->getOptionValues($product_option['option_id']); |
||
1506 | } |
||
1507 | } |
||
1508 | } |
||
1509 | |||
1510 | $this->load->model('customer/customer_group'); |
||
1511 | |||
1512 | $data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups(); |
||
1513 | |||
1514 | if (isset($this->request->post['product_discount'])) { |
||
1515 | $product_discounts = $this->request->post['product_discount']; |
||
1516 | } elseif (isset($this->request->get['product_id'])) { |
||
1517 | $product_discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); |
||
1518 | } else { |
||
1519 | $product_discounts = array(); |
||
1520 | } |
||
1521 | |||
1522 | $data['product_discounts'] = array(); |
||
1523 | |||
1524 | foreach ($product_discounts as $product_discount) { |
||
1525 | $data['product_discounts'][] = array( |
||
1526 | 'customer_group_id' => $product_discount['customer_group_id'], |
||
1527 | 'quantity' => $product_discount['quantity'], |
||
1528 | 'priority' => $product_discount['priority'], |
||
1529 | 'price' => $product_discount['price'], |
||
1530 | 'date_start' => ($product_discount['date_start'] != '2000-01-01') ? $product_discount['date_start'] : '', |
||
1531 | 'date_end' => ($product_discount['date_end'] != '2000-01-01') ? $product_discount['date_end'] : '' |
||
1532 | ); |
||
1533 | } |
||
1534 | |||
1535 | if (isset($this->request->post['product_special'])) { |
||
1536 | $product_specials = $this->request->post['product_special']; |
||
1537 | } elseif (isset($this->request->get['product_id'])) { |
||
1538 | $product_specials = $this->model_catalog_product->getProductSpecials($this->request->get['product_id']); |
||
1539 | } else { |
||
1540 | $product_specials = array(); |
||
1541 | } |
||
1542 | |||
1543 | $data['product_specials'] = array(); |
||
1544 | |||
1545 | foreach ($product_specials as $product_special) { |
||
1546 | $data['product_specials'][] = array( |
||
1547 | 'customer_group_id' => $product_special['customer_group_id'], |
||
1548 | 'priority' => $product_special['priority'], |
||
1549 | 'price' => $product_special['price'], |
||
1550 | 'date_start' => ($product_special['date_start'] != '2000-01-01') ? $product_special['date_start'] : '', |
||
1551 | 'date_end' => ($product_special['date_end'] != '2000-01-01') ? $product_special['date_end'] : '' |
||
1552 | ); |
||
1553 | } |
||
1554 | |||
1555 | // Image |
||
1556 | if (isset($this->request->post['image'])) { |
||
1557 | $data['image'] = $this->request->post['image']; |
||
1558 | } elseif (!empty($product_info)) { |
||
1559 | $data['image'] = $product_info['image']; |
||
1560 | } else { |
||
1561 | $data['image'] = ''; |
||
1562 | } |
||
1563 | |||
1564 | |||
1565 | |||
1566 | if (isset($this->request->post['image']) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
1567 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
1568 | } elseif (!empty($product_info) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $product_info['image'])) { |
||
1569 | $data['thumb'] = '/public_html/assets/images/' . $product_info['image']; |
||
1570 | } else { |
||
1571 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
1572 | } |
||
1573 | |||
1574 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
1575 | |||
1576 | // Images |
||
1577 | if (isset($this->request->post['product_image'])) { |
||
1578 | $product_images = $this->request->post['product_image']; |
||
1579 | } elseif (isset($this->request->get['product_id'])) { |
||
1580 | $product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']); |
||
1581 | } else { |
||
1582 | $product_images = array(); |
||
1583 | } |
||
1584 | |||
1585 | $data['product_images'] = array(); |
||
1586 | |||
1587 | foreach ($product_images as $product_image) { |
||
1588 | if (is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $product_image['image'])) { |
||
1589 | $image = $product_image['image']; |
||
1590 | $thumb = $product_image['image']; |
||
1591 | } else { |
||
1592 | $image = ''; |
||
1593 | $thumb = 'no_image.png'; |
||
1594 | } |
||
1595 | |||
1596 | $data['product_images'][] = array( |
||
1597 | 'image' => $image, |
||
1598 | 'thumb' => '/public_html/assets/images/' . $thumb, |
||
1599 | 'sort_order' => $product_image['sort_order'] |
||
1600 | ); |
||
1601 | } |
||
1602 | |||
1603 | // Downloads |
||
1604 | $this->load->model('catalog/download'); |
||
1605 | |||
1606 | if (isset($this->request->post['product_download'])) { |
||
1607 | $product_downloads = $this->request->post['product_download']; |
||
1608 | } elseif (isset($this->request->get['product_id'])) { |
||
1609 | $product_downloads = $this->model_catalog_product->getProductDownloads($this->request->get['product_id']); |
||
1610 | } else { |
||
1611 | $product_downloads = array(); |
||
1612 | } |
||
1613 | |||
1614 | $data['product_downloads'] = array(); |
||
1615 | |||
1616 | foreach ($product_downloads as $download_id) { |
||
1617 | $download_info = $this->model_catalog_download->getDownload($download_id); |
||
1618 | |||
1619 | if ($download_info) { |
||
1620 | $data['product_downloads'][] = array( |
||
1621 | 'download_id' => $download_info['download_id'], |
||
1622 | 'name' => $download_info['name'] |
||
1623 | ); |
||
1624 | } |
||
1625 | } |
||
1626 | |||
1627 | if (isset($this->request->post['product_related'])) { |
||
1628 | $products = $this->request->post['product_related']; |
||
1629 | } elseif (isset($this->request->get['product_id'])) { |
||
1630 | $products = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); |
||
1631 | } else { |
||
1632 | $products = array(); |
||
1633 | } |
||
1634 | |||
1635 | $data['product_relateds'] = array(); |
||
1636 | |||
1637 | foreach ($products as $product_id) { |
||
1638 | $related_info = $this->model_catalog_product->getProduct($product_id); |
||
1639 | |||
1640 | if ($related_info) { |
||
1641 | $data['product_relateds'][] = array( |
||
1642 | 'product_id' => $related_info['product_id'], |
||
1643 | 'name' => $related_info['name'] |
||
1644 | ); |
||
1645 | } |
||
1646 | } |
||
1647 | |||
1648 | if (isset($this->request->post['product_related_article'])) { |
||
1649 | $articles = $this->request->post['product_related_article']; |
||
1650 | } elseif (isset($product_info)) { |
||
1651 | $articles = $this->model_catalog_product->getArticleRelated($this->request->get['product_id']); |
||
1652 | } else { |
||
1653 | $articles = array(); |
||
1654 | } |
||
1655 | |||
1656 | $data['product_related_article'] = array(); |
||
1657 | $this->load->model('blog/article'); |
||
1658 | |||
1659 | foreach ($articles as $article_id) { |
||
1660 | $article_info = $this->model_blog_article->getArticle($article_id); |
||
1661 | |||
1662 | if ($article_info) { |
||
1663 | $data['product_related_article'][] = array( |
||
1664 | 'article_id' => $article_info['article_id'], |
||
1665 | 'name' => $article_info['name'] |
||
1666 | ); |
||
1667 | } |
||
1668 | } |
||
1669 | |||
1670 | if (isset($this->request->post['points'])) { |
||
1671 | $data['points'] = $this->request->post['points']; |
||
1672 | } elseif (!empty($product_info)) { |
||
1673 | $data['points'] = $product_info['points']; |
||
1674 | } else { |
||
1675 | $data['points'] = ''; |
||
1676 | } |
||
1677 | |||
1678 | if (isset($this->request->post['product_reward'])) { |
||
1679 | $data['product_reward'] = $this->request->post['product_reward']; |
||
1680 | } elseif (isset($this->request->get['product_id'])) { |
||
1681 | $data['product_reward'] = $this->model_catalog_product->getProductRewards($this->request->get['product_id']); |
||
1682 | } else { |
||
1683 | $data['product_reward'] = array(); |
||
1684 | } |
||
1685 | |||
1686 | if (isset($this->request->post['product_layout'])) { |
||
1687 | $data['product_layout'] = $this->request->post['product_layout']; |
||
1688 | } elseif (isset($this->request->get['product_id'])) { |
||
1689 | $data['product_layout'] = $this->model_catalog_product->getProductLayouts($this->request->get['product_id']); |
||
1690 | } else { |
||
1691 | $data['product_layout'] = array(); |
||
1692 | } |
||
1693 | |||
1694 | if (isset($this->request->post['product_tab'])) { |
||
1695 | $data['product_tabs'] = $this->request->post['product_tab']; |
||
1696 | } elseif (isset($this->request->get['product_id'])) { |
||
1697 | $data['product_tabs'] = $this->model_catalog_product->getProductTabbyProductID($this->request->get['product_id']); |
||
1698 | } else { |
||
1699 | $data['product_tabs'] = array(); |
||
1700 | } |
||
1701 | |||
1702 | $this->load->model('design/layout'); |
||
1703 | |||
1704 | $data['layouts'] = $this->model_design_layout->getLayouts(); |
||
1705 | |||
1706 | $this->load->model('design/sticker'); |
||
1707 | $data['stickers'] = $this->model_design_sticker->getStickersProduct(); |
||
1708 | |||
1709 | |||
1710 | $this->load->model('design/benefit'); |
||
1711 | $productbenefits = $this->model_design_benefit->getBenefits(); |
||
1712 | |||
1713 | $data['benefits'] = array(); |
||
1714 | |||
1715 | foreach ($productbenefits as $benefit) { |
||
1716 | if ($benefit['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $benefit['image'])) { |
||
1717 | $image = '/public_html/assets/images/' . $benefit['image']; |
||
1718 | } else { |
||
1719 | $image = '/public_html/assets/images/no_image.png'; |
||
1720 | } |
||
1721 | $data['benefits'][] = array( |
||
1722 | 'benefit_id' => $benefit['benefit_id'], |
||
1723 | 'name' => $benefit['name'], |
||
1724 | 'thumb' => $image |
||
1725 | ); |
||
1726 | } |
||
1727 | |||
1728 | |||
1729 | if (isset($this->request->post['product_benefits'])) { |
||
1730 | $data['product_benefits'] = $this->request->post['product_benefits']; |
||
1731 | } elseif (isset($this->request->get['product_id'])) { |
||
1732 | $data['product_benefits'] = $this->model_catalog_product->getBenefits($this->request->get['product_id']); |
||
1733 | } else { |
||
1734 | $data['product_benefits'] = array(); |
||
1735 | } |
||
1736 | |||
1737 | |||
1738 | if (isset($this->request->post['product_stickers'])) { |
||
1739 | $data['product_stickers'] = $this->request->post['product_stickers']; |
||
1740 | } elseif (isset($this->request->get['product_id'])) { |
||
1741 | $data['product_stickers'] = $this->model_design_sticker->getProductSticker($this->request->get['product_id']); |
||
1742 | } else { |
||
1743 | $data['product_stickers'] = array(); |
||
1744 | } |
||
1745 | |||
1746 | $data['header'] = $this->load->controller('common/header'); |
||
1747 | $data['column'] = $this->load->controller('common/column_left'); |
||
1748 | $data['footer'] = $this->load->controller('common/footer'); |
||
1749 | |||
1750 | $this->response->setOutput($this->load->view('catalog/product_form', $data)); |
||
1751 | } |
||
1752 | |||
1753 | protected function validateForm() |
||
1754 | { |
||
1755 | if (!$this->user->hasPermission('modify', 'catalog/product')) { |
||
1756 | $this->error['warning'] = $this->language->get('error_permission'); |
||
1757 | } |
||
1758 | |||
1759 | if (isset($this->request->post['product_tab'])) { |
||
1760 | foreach ($this->request->post['product_tab'] as $key => $tab) { |
||
1761 | if ($tab) { |
||
1762 | foreach ($tab['description'] as $language_id => $value) { |
||
1763 | if (empty($value['heading'])) { |
||
1764 | $this->error['tab'][$key][$language_id] = $this->language->get('error_tab'); |
||
1765 | } |
||
1766 | } |
||
1767 | } |
||
1768 | } |
||
1769 | } |
||
1770 | |||
1771 | foreach ($this->request->post['product_description'] as $language_id => $value) { |
||
1772 | if ((\voku\helper\UTF8::strlen($value['name']) < 3) || (\voku\helper\UTF8::strlen($value['name']) > 255)) { |
||
1773 | $this->error['name'][$language_id] = $this->language->get('error_name'); |
||
1774 | } |
||
1775 | |||
1776 | if ((\voku\helper\UTF8::strlen($value['meta_title']) < 0) || (\voku\helper\UTF8::strlen($value['meta_title']) > 255)) { |
||
1777 | $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title'); |
||
1778 | } |
||
1779 | |||
1780 | if ((\voku\helper\UTF8::strlen($value['meta_h1']) < 0) || (\voku\helper\UTF8::strlen($value['meta_h1']) > 255)) { |
||
1781 | $this->error['meta_h1'][$language_id] = $this->language->get('error_meta_h1'); |
||
1782 | } |
||
1783 | } |
||
1784 | |||
1785 | if ((\voku\helper\UTF8::strlen($this->request->post['model']) < 1) || (\voku\helper\UTF8::strlen($this->request->post['model']) > 64)) { |
||
1786 | $this->error['model'] = $this->language->get('error_model'); |
||
1787 | } |
||
1788 | |||
1789 | if (\voku\helper\UTF8::strlen($this->request->post['keyword']) > 0) { |
||
1790 | $this->load->model('catalog/url_alias'); |
||
1791 | |||
1792 | $url_alias_info = $this->model_catalog_url_alias->getUrlAlias($this->request->post['keyword']); |
||
1793 | |||
1794 | if ($url_alias_info && isset($this->request->get['product_id']) && $url_alias_info['query'] != 'product_id=' . $this->request->get['product_id']) { |
||
1795 | $this->error['keyword'] = sprintf($this->language->get('error_keyword')); |
||
1796 | } |
||
1797 | |||
1798 | if ($url_alias_info && !isset($this->request->get['product_id'])) { |
||
1799 | $this->error['keyword'] = sprintf($this->language->get('error_keyword')); |
||
1800 | } |
||
1801 | } |
||
1802 | |||
1803 | if ($this->error && !isset($this->error['warning'])) { |
||
1804 | $this->error['warning'] = $this->language->get('error_warning'); |
||
1805 | } |
||
1806 | |||
1807 | return !$this->error; |
||
1808 | } |
||
1809 | |||
1810 | public function enable() |
||
1811 | { |
||
1812 | $this->load->language('catalog/product'); |
||
1813 | $this->document->setTitle($this->language->get('heading_title')); |
||
1814 | $this->load->model('catalog/product'); |
||
1815 | if (isset($this->request->post['selected'])) { |
||
1816 | foreach ($this->request->post['selected'] as $product_id) { |
||
1817 | $this->model_catalog_product->editProductStatus($product_id, 1); |
||
1818 | } |
||
1819 | $this->session->data['success'] = $this->language->get('text_success'); |
||
1820 | $url = ''; |
||
1821 | if (isset($this->request->get['page'])) { |
||
1822 | $url .= '&page=' . $this->request->get['page']; |
||
1823 | } |
||
1824 | if (isset($this->request->get['sort'])) { |
||
1825 | $url .= '&sort=' . $this->request->get['sort']; |
||
1826 | } |
||
1827 | if (isset($this->request->get['order'])) { |
||
1828 | $url .= '&order=' . $this->request->get['order']; |
||
1829 | } |
||
1830 | $this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true)); |
||
1831 | } |
||
1832 | $this->getList(); |
||
1833 | } |
||
1834 | public function disable() |
||
1835 | { |
||
1836 | $this->load->language('catalog/product'); |
||
1837 | $this->document->setTitle($this->language->get('heading_title')); |
||
1838 | $this->load->model('catalog/product'); |
||
1839 | if (isset($this->request->post['selected'])) { |
||
1840 | foreach ($this->request->post['selected'] as $product_id) { |
||
1841 | $this->model_catalog_product->editProductStatus($product_id, 0); |
||
1842 | } |
||
1843 | $this->session->data['success'] = $this->language->get('text_success'); |
||
1844 | $url = ''; |
||
1845 | if (isset($this->request->get['page'])) { |
||
1846 | $url .= '&page=' . $this->request->get['page']; |
||
1847 | } |
||
1848 | if (isset($this->request->get['sort'])) { |
||
1849 | $url .= '&sort=' . $this->request->get['sort']; |
||
1850 | } |
||
1851 | if (isset($this->request->get['order'])) { |
||
1852 | $url .= '&order=' . $this->request->get['order']; |
||
1853 | } |
||
1854 | $this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true)); |
||
1855 | } |
||
1856 | $this->getList(); |
||
1857 | } |
||
1858 | |||
1859 | protected function validateDelete() |
||
1860 | { |
||
1861 | if (!$this->user->hasPermission('modify', 'catalog/product')) { |
||
1862 | $this->error['warning'] = $this->language->get('error_permission'); |
||
1863 | } |
||
1864 | |||
1865 | return !$this->error; |
||
1866 | } |
||
1867 | |||
1868 | protected function validateCopy() |
||
1869 | { |
||
1870 | if (!$this->user->hasPermission('modify', 'catalog/product')) { |
||
1871 | $this->error['warning'] = $this->language->get('error_permission'); |
||
1872 | } |
||
1873 | |||
1874 | return !$this->error; |
||
1875 | } |
||
1876 | |||
1877 | public function autocomplete() |
||
1961 | } |
||
1962 | } |
||
1963 |
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.