/mall/upload/catalog/controller/supplier/product.php

https://bitbucket.org/allanxyh/uniquemall · PHP · 1292 lines · 1008 code · 258 blank · 26 comment · 255 complexity · 9d93582ea497aa8f154df686aad59bbe MD5 · raw file

  1. <?php
  2. class ControllerSupplierProduct extends Controller {
  3. private $error = array();
  4. public function index() {
  5. if (!$this->supplier->isLogged()) {// $this->session->data['supplier_id']
  6. $this->session->data['redirect'] = $this->url->link('supplier/account', '', 'SSL');
  7. $this->redirect($this->url->link('supplier/login', '', 'SSL'));
  8. }
  9. $this->language->load('supplier/product');
  10. $this->document->setTitle($this->language->get('heading_title'));
  11. $this->load->model('supplier/product');
  12. $this->getList();
  13. }
  14. public function insert() {
  15. $this->language->load('catalog/product');
  16. $this->document->setTitle($this->language->get('heading_title'));
  17. $this->load->model('catalog/product');
  18. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  19. $this->model_catalog_product->addProduct($this->request->post);
  20. $this->session->data['success'] = $this->language->get('text_success');
  21. $url = '';
  22. if (isset($this->request->get['filter_name'])) {
  23. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  24. }
  25. if (isset($this->request->get['filter_model'])) {
  26. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  27. }
  28. //添加推荐人
  29. if (isset($this->request->get['filter_referrer'])) {
  30. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  31. }
  32. //添加供货商
  33. if (isset($this->request->get['filter_supplier'])) {
  34. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  35. }
  36. if (isset($this->request->get['filter_price'])) {
  37. $url .= '&filter_price=' . $this->request->get['filter_price'];
  38. }
  39. if (isset($this->request->get['filter_quantity'])) {
  40. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  41. }
  42. if (isset($this->request->get['filter_status'])) {
  43. $url .= '&filter_status=' . $this->request->get['filter_status'];
  44. }
  45. if (isset($this->request->get['sort'])) {
  46. $url .= '&sort=' . $this->request->get['sort'];
  47. }
  48. if (isset($this->request->get['order'])) {
  49. $url .= '&order=' . $this->request->get['order'];
  50. }
  51. if (isset($this->request->get['page'])) {
  52. $url .= '&page=' . $this->request->get['page'];
  53. }
  54. $this->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  55. }
  56. $this->getForm();
  57. }
  58. public function update() {
  59. $this->language->load('catalog/product');
  60. $this->document->setTitle($this->language->get('heading_title'));
  61. $this->load->model('supplier/product');
  62. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  63. $this->model_supplier_product->editProduct($this->request->get['product_id'], $this->request->post);
  64. $this->session->data['success'] = $this->language->get('text_success');
  65. $url = '';
  66. if (isset($this->request->get['filter_name'])) {
  67. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  68. }
  69. if (isset($this->request->get['filter_model'])) {
  70. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  71. }
  72. //添加推荐人
  73. if (isset($this->request->get['filter_referrer'])) {
  74. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  75. }
  76. //添加供货商
  77. if (isset($this->request->get['filter_supplier'])) {
  78. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  79. }
  80. if (isset($this->request->get['filter_price'])) {
  81. $url .= '&filter_price=' . $this->request->get['filter_price'];
  82. }
  83. if (isset($this->request->get['filter_quantity'])) {
  84. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  85. }
  86. if (isset($this->request->get['filter_status'])) {
  87. $url .= '&filter_status=' . $this->request->get['filter_status'];
  88. }
  89. if (isset($this->request->get['sort'])) {
  90. $url .= '&sort=' . $this->request->get['sort'];
  91. }
  92. if (isset($this->request->get['order'])) {
  93. $url .= '&order=' . $this->request->get['order'];
  94. }
  95. if (isset($this->request->get['page'])) {
  96. $url .= '&page=' . $this->request->get['page'];
  97. }
  98. $this->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  99. }
  100. $this->getForm();
  101. }
  102. public function delete() {
  103. $this->language->load('catalog/product');
  104. $this->document->setTitle($this->language->get('heading_title'));
  105. $this->load->model('catalog/product');
  106. if (isset($this->request->post['selected']) && $this->validateDelete()) {
  107. foreach ($this->request->post['selected'] as $product_id) {
  108. $this->model_catalog_product->deleteProduct($product_id);
  109. }
  110. $this->session->data['success'] = $this->language->get('text_success');
  111. $url = '';
  112. if (isset($this->request->get['filter_name'])) {
  113. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  114. }
  115. if (isset($this->request->get['filter_model'])) {
  116. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  117. }
  118. //添加推荐人
  119. if (isset($this->request->get['filter_referrer'])) {
  120. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  121. }
  122. //添加供货商
  123. if (isset($this->request->get['filter_supplier'])) {
  124. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  125. }
  126. if (isset($this->request->get['filter_price'])) {
  127. $url .= '&filter_price=' . $this->request->get['filter_price'];
  128. }
  129. if (isset($this->request->get['filter_quantity'])) {
  130. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  131. }
  132. if (isset($this->request->get['filter_status'])) {
  133. $url .= '&filter_status=' . $this->request->get['filter_status'];
  134. }
  135. if (isset($this->request->get['sort'])) {
  136. $url .= '&sort=' . $this->request->get['sort'];
  137. }
  138. if (isset($this->request->get['order'])) {
  139. $url .= '&order=' . $this->request->get['order'];
  140. }
  141. if (isset($this->request->get['page'])) {
  142. $url .= '&page=' . $this->request->get['page'];
  143. }
  144. $this->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  145. }
  146. $this->getList();
  147. }
  148. public function copy() {
  149. $this->language->load('catalog/product');
  150. $this->document->setTitle($this->language->get('heading_title'));
  151. $this->load->model('catalog/product');
  152. if (isset($this->request->post['selected']) && $this->validateCopy()) {
  153. foreach ($this->request->post['selected'] as $product_id) {
  154. $this->model_catalog_product->copyProduct($product_id);
  155. }
  156. $this->session->data['success'] = $this->language->get('text_success');
  157. $url = '';
  158. if (isset($this->request->get['filter_name'])) {
  159. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  160. }
  161. if (isset($this->request->get['filter_model'])) {
  162. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  163. }
  164. //添加推荐人
  165. if (isset($this->request->get['filter_referrer'])) {
  166. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  167. }
  168. //添加供货商
  169. if (isset($this->request->get['filter_supplier'])) {
  170. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  171. }
  172. if (isset($this->request->get['filter_price'])) {
  173. $url .= '&filter_price=' . $this->request->get['filter_price'];
  174. }
  175. if (isset($this->request->get['filter_quantity'])) {
  176. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  177. }
  178. if (isset($this->request->get['filter_status'])) {
  179. $url .= '&filter_status=' . $this->request->get['filter_status'];
  180. }
  181. if (isset($this->request->get['sort'])) {
  182. $url .= '&sort=' . $this->request->get['sort'];
  183. }
  184. if (isset($this->request->get['order'])) {
  185. $url .= '&order=' . $this->request->get['order'];
  186. }
  187. if (isset($this->request->get['page'])) {
  188. $url .= '&page=' . $this->request->get['page'];
  189. }
  190. $this->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  191. }
  192. $this->getList();
  193. }
  194. protected function getList() {
  195. if (isset($this->request->get['filter_name'])) {
  196. $filter_name = $this->request->get['filter_name'];
  197. } else {
  198. $filter_name = null;
  199. }
  200. if (isset($this->request->get['filter_model'])) {
  201. $filter_model = $this->request->get['filter_model'];
  202. } else {
  203. $filter_model = null;
  204. }
  205. //添加推荐人
  206. if (isset($this->request->get['filter_referrer'])) {
  207. $filter_referrer = $this->request->get['filter_referrer'];
  208. } else {
  209. $filter_referrer = null;
  210. }
  211. //添加供货商
  212. if (isset($this->request->get['filter_supplier'])) {
  213. $filter_supplier = $this->request->get['filter_supplier'];
  214. } else {
  215. $filter_supplier = null;
  216. }
  217. if (isset($this->request->get['filter_price'])) {
  218. $filter_price = $this->request->get['filter_price'];
  219. } else {
  220. $filter_price = null;
  221. }
  222. if (isset($this->request->get['filter_quantity'])) {
  223. $filter_quantity = $this->request->get['filter_quantity'];
  224. } else {
  225. $filter_quantity = null;
  226. }
  227. if (isset($this->request->get['filter_status'])) {
  228. $filter_status = $this->request->get['filter_status'];
  229. } else {
  230. $filter_status = null;
  231. }
  232. if (isset($this->request->get['sort'])) {
  233. $sort = $this->request->get['sort'];
  234. } else {
  235. $sort = 'pd.name';
  236. }
  237. if (isset($this->request->get['order'])) {
  238. $order = $this->request->get['order'];
  239. } else {
  240. $order = 'ASC';
  241. }
  242. if (isset($this->request->get['page'])) {
  243. $page = $this->request->get['page'];
  244. } else {
  245. $page = 1;
  246. }
  247. $url = '';
  248. if (isset($this->request->get['filter_name'])) {
  249. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  250. }
  251. if (isset($this->request->get['filter_model'])) {
  252. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  253. }
  254. //添加推荐人
  255. if (isset($this->request->get['filter_referrer'])) {
  256. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  257. }
  258. //添加供货商
  259. if (isset($this->request->get['filter_supplier'])) {
  260. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  261. }
  262. if (isset($this->request->get['filter_price'])) {
  263. $url .= '&filter_price=' . $this->request->get['filter_price'];
  264. }
  265. if (isset($this->request->get['filter_quantity'])) {
  266. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  267. }
  268. if (isset($this->request->get['filter_status'])) {
  269. $url .= '&filter_status=' . $this->request->get['filter_status'];
  270. }
  271. if (isset($this->request->get['sort'])) {
  272. $url .= '&sort=' . $this->request->get['sort'];
  273. }
  274. if (isset($this->request->get['order'])) {
  275. $url .= '&order=' . $this->request->get['order'];
  276. }
  277. if (isset($this->request->get['page'])) {
  278. $url .= '&page=' . $this->request->get['page'];
  279. }
  280. //$this->data['insert'] = $this->url->link('catalog/product/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
  281. //$this->data['copy'] = $this->url->link('catalog/product/copy', 'token=' . $this->session->data['token'] . $url, 'SSL');
  282. //$this->data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
  283. $this->data['products'] = array();
  284. $sid = $this->supplier->getSid();
  285. $data = array(
  286. 'filter_name' => $filter_name,
  287. 'filter_model' => $filter_model,
  288. 'filter_price' => $filter_price,
  289. 'filter_quantity' => $filter_quantity,
  290. 'filter_status' => $filter_status,
  291. 'sort' => $sort,
  292. 'order' => $order,
  293. 'start' => ($page - 1) * $this->config->get('config_admin_limit'),
  294. 'limit' => $this->config->get('config_admin_limit'),
  295. 'supplier' => $sid
  296. );
  297. $this->load->model('tool/image');
  298. $product_total = $this->model_supplier_product->getTotalProducts($data);
  299. $results = $this->model_supplier_product->getProducts($data);
  300. foreach ($results as $result) {
  301. $action = array();
  302. $action[] = array(
  303. 'text' => $this->language->get('text_sale'),
  304. 'href' => $this->url->link('report/product_purchased', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL')
  305. );
  306. if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) {
  307. $image = $this->model_tool_image->resize($result['image'], 40, 40);
  308. } else {
  309. $image = $this->model_tool_image->resize('no_image.jpg', 40, 40);
  310. }
  311. $special = false;
  312. $product_specials = $this->model_supplier_product->getProductSpecials($result['product_id']);
  313. foreach ($product_specials as $product_special) {
  314. if (($product_special['date_start'] == '0000-00-00' || $product_special['date_start'] < date('Y-m-d')) && ($product_special['date_end'] == '0000-00-00' || $product_special['date_end'] > date('Y-m-d'))) {
  315. $special = $product_special['price'];
  316. break;
  317. }
  318. }
  319. $this->data['products'][] = array(
  320. 'product_id' => $result['product_id'],
  321. 'name' => $result['name'],
  322. 'model' => $result['model'],
  323. 'referrer' => $result['referrer'],
  324. 'supplier' => $result['supplier'],
  325. 'price' => $result['price'],
  326. 'special' => $special,
  327. 'image' => $image,
  328. 'quantity' => $result['quantity'],
  329. 'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
  330. 'selected' => isset($this->request->post['selected']) && in_array($result['product_id'], $this->request->post['selected']),
  331. 'action' => $action
  332. );
  333. }
  334. $this->data['heading_title'] = $this->language->get('heading_title');
  335. $this->data['text_enabled'] = $this->language->get('text_enabled');
  336. $this->data['text_disabled'] = $this->language->get('text_disabled');
  337. $this->data['text_no_results'] = $this->language->get('text_no_results');
  338. $this->data['text_image_manager'] = $this->language->get('text_image_manager');
  339. $this->data['column_image'] = $this->language->get('column_image');
  340. $this->data['column_name'] = $this->language->get('column_name');
  341. $this->data['column_model'] = $this->language->get('column_model');
  342. $this->data['column_referrer'] = $this->language->get('column_referrer');//推荐人
  343. $this->data['column_supplier'] = $this->language->get('column_supplier');//供货商
  344. $this->data['column_price'] = $this->language->get('column_price');
  345. $this->data['column_quantity'] = $this->language->get('column_quantity');
  346. $this->data['column_status'] = $this->language->get('column_status');
  347. $this->data['column_action'] = $this->language->get('column_action');
  348. $this->data['button_copy'] = $this->language->get('button_copy');
  349. $this->data['button_insert'] = $this->language->get('button_insert');
  350. $this->data['button_delete'] = $this->language->get('button_delete');
  351. $this->data['button_filters'] = $this->language->get('button_filters');
  352. $this->data['token'] = $this->session->data['token'];
  353. if (isset($this->error['warning'])) {
  354. $this->data['error_warning'] = $this->error['warning'];
  355. } else {
  356. $this->data['error_warning'] = '';
  357. }
  358. if (isset($this->session->data['success'])) {
  359. $this->data['success'] = $this->session->data['success'];
  360. unset($this->session->data['success']);
  361. } else {
  362. $this->data['success'] = '';
  363. }
  364. $url = '';
  365. if (isset($this->request->get['filter_name'])) {
  366. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  367. }
  368. if (isset($this->request->get['filter_model'])) {
  369. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  370. }
  371. //添加推荐人
  372. if (isset($this->request->get['filter_referrer'])) {
  373. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  374. }
  375. //添加供货商
  376. if (isset($this->request->get['filter_supplier'])) {
  377. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  378. }
  379. if (isset($this->request->get['filter_price'])) {
  380. $url .= '&filter_price=' . $this->request->get['filter_price'];
  381. }
  382. if (isset($this->request->get['filter_quantity'])) {
  383. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  384. }
  385. if (isset($this->request->get['filter_status'])) {
  386. $url .= '&filter_status=' . $this->request->get['filter_status'];
  387. }
  388. if ($order == 'ASC') {
  389. $url .= '&order=DESC';
  390. } else {
  391. $url .= '&order=ASC';
  392. }
  393. if (isset($this->request->get['page'])) {
  394. $url .= '&page=' . $this->request->get['page'];
  395. }
  396. $this->data['sort_name'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, 'SSL');
  397. $this->data['sort_model'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.model' . $url, 'SSL');
  398. $this->data['sort_referrer'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.referrer' . $url, 'SSL');
  399. $this->data['sort_supplier'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.supplier' . $url, 'SSL');
  400. $this->data['sort_price'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.price' . $url, 'SSL');
  401. $this->data['sort_quantity'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.quantity' . $url, 'SSL');
  402. $this->data['sort_status'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.status' . $url, 'SSL');
  403. $this->data['sort_order'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url, 'SSL');
  404. $url = '';
  405. if (isset($this->request->get['filter_name'])) {
  406. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  407. }
  408. if (isset($this->request->get['filter_model'])) {
  409. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  410. }
  411. //添加推荐人
  412. if (isset($this->request->get['filter_referrer'])) {
  413. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  414. }
  415. //添加供货商
  416. if (isset($this->request->get['filter_supplier'])) {
  417. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  418. }
  419. if (isset($this->request->get['filter_price'])) {
  420. $url .= '&filter_price=' . $this->request->get['filter_price'];
  421. }
  422. if (isset($this->request->get['filter_quantity'])) {
  423. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  424. }
  425. if (isset($this->request->get['filter_status'])) {
  426. $url .= '&filter_status=' . $this->request->get['filter_status'];
  427. }
  428. if (isset($this->request->get['sort'])) {
  429. $url .= '&sort=' . $this->request->get['sort'];
  430. }
  431. if (isset($this->request->get['order'])) {
  432. $url .= '&order=' . $this->request->get['order'];
  433. }
  434. $pagination = new Pagination();
  435. $pagination->total = $product_total;
  436. $pagination->page = $page;
  437. $pagination->limit = $this->config->get('config_admin_limit');
  438. $pagination->text = $this->language->get('text_pagination');
  439. $pagination->url = $this->url->link('supplier/product', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  440. $this->data['pagination'] = $pagination->render();
  441. $this->data['filter_name'] = $filter_name;
  442. $this->data['filter_model'] = $filter_model;
  443. $this->data['filter_referrer'] = $filter_referrer;
  444. $this->data['filter_supplier'] = $filter_supplier;
  445. $this->data['filter_price'] = $filter_price;
  446. $this->data['filter_quantity'] = $filter_quantity;
  447. $this->data['filter_status'] = $filter_status;
  448. $this->data['sort'] = $sort;
  449. $this->data['order'] = $order;
  450. $this->template = 'default/template/supplier/product_list.tpl';
  451. $this->children = array(
  452. 'common/header',
  453. 'common/footer'
  454. );
  455. $this->response->setOutput($this->render());
  456. }
  457. protected function getForm() {
  458. $this->data['heading_title'] = $this->language->get('heading_title');
  459. $this->data['text_enabled'] = $this->language->get('text_enabled');
  460. $this->data['text_disabled'] = $this->language->get('text_disabled');
  461. $this->data['text_none'] = $this->language->get('text_none');
  462. $this->data['text_yes'] = $this->language->get('text_yes');
  463. $this->data['text_no'] = $this->language->get('text_no');
  464. $this->data['text_plus'] = $this->language->get('text_plus');
  465. $this->data['text_minus'] = $this->language->get('text_minus');
  466. $this->data['text_default'] = $this->language->get('text_default');
  467. $this->data['text_image_manager'] = $this->language->get('text_image_manager');
  468. $this->data['text_browse'] = $this->language->get('text_browse');
  469. $this->data['text_clear'] = $this->language->get('text_clear');
  470. $this->data['text_option'] = $this->language->get('text_option');
  471. $this->data['text_option_value'] = $this->language->get('text_option_value');
  472. $this->data['text_select'] = $this->language->get('text_select');
  473. $this->data['text_none'] = $this->language->get('text_none');
  474. $this->data['text_percent'] = $this->language->get('text_percent');
  475. $this->data['text_amount'] = $this->language->get('text_amount');
  476. $this->data['entry_name'] = $this->language->get('entry_name');
  477. $this->data['entry_referrer'] = $this->language->get('entry_referrer'); //添加
  478. $this->data['entry_supplier'] = $this->language->get('entry_supplier'); //添加
  479. $this->data['entry_meta_description'] = $this->language->get('entry_meta_description');
  480. $this->data['entry_meta_keyword'] = $this->language->get('entry_meta_keyword');
  481. $this->data['entry_description'] = $this->language->get('entry_description');
  482. $this->data['entry_store'] = $this->language->get('entry_store');
  483. $this->data['entry_keyword'] = $this->language->get('entry_keyword');
  484. $this->data['entry_model'] = $this->language->get('entry_model');
  485. $this->data['entry_sku'] = $this->language->get('entry_sku');
  486. $this->data['entry_upc'] = $this->language->get('entry_upc');
  487. $this->data['entry_ean'] = $this->language->get('entry_ean');
  488. $this->data['entry_jan'] = $this->language->get('entry_jan');
  489. $this->data['entry_isbn'] = $this->language->get('entry_isbn');
  490. $this->data['entry_mpn'] = $this->language->get('entry_mpn');
  491. $this->data['entry_location'] = $this->language->get('entry_location');
  492. $this->data['entry_minimum'] = $this->language->get('entry_minimum');
  493. $this->data['entry_manufacturer'] = $this->language->get('entry_manufacturer');
  494. $this->data['entry_shipping'] = $this->language->get('entry_shipping');
  495. $this->data['entry_date_available'] = $this->language->get('entry_date_available');
  496. $this->data['entry_quantity'] = $this->language->get('entry_quantity');
  497. $this->data['entry_stock_status'] = $this->language->get('entry_stock_status');
  498. $this->data['entry_price'] = $this->language->get('entry_price');
  499. $this->data['entry_tax_class'] = $this->language->get('entry_tax_class');
  500. $this->data['entry_points'] = $this->language->get('entry_points');
  501. $this->data['entry_option_points'] = $this->language->get('entry_option_points');
  502. $this->data['entry_subtract'] = $this->language->get('entry_subtract');
  503. $this->data['entry_weight_class'] = $this->language->get('entry_weight_class');
  504. $this->data['entry_weight'] = $this->language->get('entry_weight');
  505. $this->data['entry_dimension'] = $this->language->get('entry_dimension');
  506. $this->data['entry_length'] = $this->language->get('entry_length');
  507. $this->data['entry_image'] = $this->language->get('entry_image');
  508. $this->data['entry_download'] = $this->language->get('entry_download');
  509. $this->data['entry_category'] = $this->language->get('entry_category');
  510. $this->data['entry_filter'] = $this->language->get('entry_filter');
  511. $this->data['entry_related'] = $this->language->get('entry_related');
  512. $this->data['entry_attribute'] = $this->language->get('entry_attribute');
  513. $this->data['entry_text'] = $this->language->get('entry_text');
  514. $this->data['entry_option'] = $this->language->get('entry_option');
  515. $this->data['entry_option_value'] = $this->language->get('entry_option_value');
  516. $this->data['entry_required'] = $this->language->get('entry_required');
  517. $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
  518. $this->data['entry_status'] = $this->language->get('entry_status');
  519. $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
  520. $this->data['entry_date_start'] = $this->language->get('entry_date_start');
  521. $this->data['entry_date_end'] = $this->language->get('entry_date_end');
  522. $this->data['entry_priority'] = $this->language->get('entry_priority');
  523. $this->data['entry_tag'] = $this->language->get('entry_tag');
  524. $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
  525. $this->data['entry_reward'] = $this->language->get('entry_reward');
  526. $this->data['entry_layout'] = $this->language->get('entry_layout');
  527. $this->data['button_save'] = $this->language->get('button_save');
  528. $this->data['button_cancel'] = $this->language->get('button_cancel');
  529. $this->data['button_add_attribute'] = $this->language->get('button_add_attribute');
  530. $this->data['button_add_option'] = $this->language->get('button_add_option');
  531. $this->data['button_add_option_value'] = $this->language->get('button_add_option_value');
  532. $this->data['button_add_discount'] = $this->language->get('button_add_discount');
  533. $this->data['button_add_special'] = $this->language->get('button_add_special');
  534. $this->data['button_add_image'] = $this->language->get('button_add_image');
  535. $this->data['button_remove'] = $this->language->get('button_remove');
  536. $this->data['tab_general'] = $this->language->get('tab_general');
  537. $this->data['tab_data'] = $this->language->get('tab_data');
  538. $this->data['tab_attribute'] = $this->language->get('tab_attribute');
  539. $this->data['tab_option'] = $this->language->get('tab_option');
  540. $this->data['tab_discount'] = $this->language->get('tab_discount');
  541. $this->data['tab_special'] = $this->language->get('tab_special');
  542. $this->data['tab_image'] = $this->language->get('tab_image');
  543. $this->data['tab_links'] = $this->language->get('tab_links');
  544. $this->data['tab_reward'] = $this->language->get('tab_reward');
  545. $this->data['tab_design'] = $this->language->get('tab_design');
  546. if (isset($this->error['warning'])) {
  547. $this->data['error_warning'] = $this->error['warning'];
  548. } else {
  549. $this->data['error_warning'] = '';
  550. }
  551. if (isset($this->error['name'])) {
  552. $this->data['error_name'] = $this->error['name'];
  553. } else {
  554. $this->data['error_name'] = array();
  555. }
  556. if (isset($this->error['meta_description'])) {
  557. $this->data['error_meta_description'] = $this->error['meta_description'];
  558. } else {
  559. $this->data['error_meta_description'] = array();
  560. }
  561. if (isset($this->error['description'])) {
  562. $this->data['error_description'] = $this->error['description'];
  563. } else {
  564. $this->data['error_description'] = array();
  565. }
  566. if (isset($this->error['model'])) {
  567. $this->data['error_model'] = $this->error['model'];
  568. } else {
  569. $this->data['error_model'] = '';
  570. }
  571. if (isset($this->error['referrer'])) {
  572. $this->data['error_referrer'] = $this->error['referrer'];
  573. } else {
  574. $this->data['error_referrer'] = '';
  575. }
  576. if (isset($this->error['supplier'])) {
  577. $this->data['error_supplier'] = $this->error['supplier'];
  578. } else {
  579. $this->data['error_supplier'] = '';
  580. }
  581. if (isset($this->error['date_available'])) {
  582. $this->data['error_date_available'] = $this->error['date_available'];
  583. } else {
  584. $this->data['error_date_available'] = '';
  585. }
  586. $url = '';
  587. if (isset($this->request->get['filter_name'])) {
  588. $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
  589. }
  590. if (isset($this->request->get['filter_model'])) {
  591. $url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
  592. }
  593. //添加推荐人
  594. if (isset($this->request->get['filter_referrer'])) {
  595. $url .= '&filter_referrer=' . urlencode(html_entity_decode($this->request->get['filter_referrer'], ENT_QUOTES, 'UTF-8'));
  596. }
  597. //添加供货商
  598. if (isset($this->request->get['filter_supplier'])) {
  599. $url .= '&filter_supplier=' . urlencode(html_entity_decode($this->request->get['filter_supplier'], ENT_QUOTES, 'UTF-8'));
  600. }
  601. if (isset($this->request->get['filter_price'])) {
  602. $url .= '&filter_price=' . $this->request->get['filter_price'];
  603. }
  604. if (isset($this->request->get['filter_quantity'])) {
  605. $url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
  606. }
  607. if (isset($this->request->get['filter_status'])) {
  608. $url .= '&filter_status=' . $this->request->get['filter_status'];
  609. }
  610. if (isset($this->request->get['sort'])) {
  611. $url .= '&sort=' . $this->request->get['sort'];
  612. }
  613. if (isset($this->request->get['order'])) {
  614. $url .= '&order=' . $this->request->get['order'];
  615. }
  616. if (isset($this->request->get['page'])) {
  617. $url .= '&page=' . $this->request->get['page'];
  618. }
  619. $this->data['breadcrumbs'] = array();
  620. $this->data['breadcrumbs'][] = array(
  621. 'text' => $this->language->get('text_home'),
  622. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  623. 'separator' => false
  624. );
  625. $this->data['breadcrumbs'][] = array(
  626. 'text' => $this->language->get('heading_title'),
  627. 'href' => $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'),
  628. 'separator' => ' :: '
  629. );
  630. if (!isset($this->request->get['product_id'])) {
  631. $this->data['action'] = $this->url->link('catalog/product/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
  632. } else {
  633. $this->data['action'] = $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $this->request->get['product_id'] . $url, 'SSL');
  634. }
  635. $this->data['cancel'] = $this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL');
  636. if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
  637. $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
  638. }
  639. $this->data['token'] = $this->session->data['token'];
  640. $this->load->model('localisation/language');
  641. $this->data['languages'] = $this->model_localisation_language->getLanguages();
  642. if (isset($this->request->post['product_description'])) {
  643. $this->data['product_description'] = $this->request->post['product_description'];
  644. } elseif (isset($this->request->get['product_id'])) {
  645. $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
  646. } else {
  647. $this->data['product_description'] = array();
  648. }
  649. if (isset($this->request->post['model'])) {
  650. $this->data['model'] = $this->request->post['model'];
  651. } elseif (!empty($product_info)) {
  652. $this->data['model'] = $product_info['model'];
  653. } else {
  654. $this->data['model'] = '';
  655. }
  656. if (isset($this->request->post['referrer'])) {
  657. $this->data['referrer'] = $this->request->post['referrer'];
  658. } elseif (!empty($product_info)) {
  659. $this->data['referrer'] = $product_info['referrer'];
  660. } else {
  661. $this->data['referrer'] = '';
  662. }
  663. if (isset($this->request->post['supplier'])) {
  664. $this->data['supplier'] = $this->request->post['supplier'];
  665. } elseif (!empty($product_info)) {
  666. $this->data['supplier'] = $product_info['supplier'];
  667. } else {
  668. $this->data['supplier'] = '';
  669. }
  670. if (isset($this->request->post['sku'])) {
  671. $this->data['sku'] = $this->request->post['sku'];
  672. } elseif (!empty($product_info)) {
  673. $this->data['sku'] = $product_info['sku'];
  674. } else {
  675. $this->data['sku'] = '';
  676. }
  677. if (isset($this->request->post['upc'])) {
  678. $this->data['upc'] = $this->request->post['upc'];
  679. } elseif (!empty($product_info)) {
  680. $this->data['upc'] = $product_info['upc'];
  681. } else {
  682. $this->data['upc'] = '';
  683. }
  684. if (isset($this->request->post['ean'])) {
  685. $this->data['ean'] = $this->request->post['ean'];
  686. } elseif (!empty($product_info)) {
  687. $this->data['ean'] = $product_info['ean'];
  688. } else {
  689. $this->data['ean'] = '';
  690. }
  691. if (isset($this->request->post['jan'])) {
  692. $this->data['jan'] = $this->request->post['jan'];
  693. } elseif (!empty($product_info)) {
  694. $this->data['jan'] = $product_info['jan'];
  695. } else {
  696. $this->data['jan'] = '';
  697. }
  698. if (isset($this->request->post['isbn'])) {
  699. $this->data['isbn'] = $this->request->post['isbn'];
  700. } elseif (!empty($product_info)) {
  701. $this->data['isbn'] = $product_info['isbn'];
  702. } else {
  703. $this->data['isbn'] = '';
  704. }
  705. if (isset($this->request->post['mpn'])) {
  706. $this->data['mpn'] = $this->request->post['mpn'];
  707. } elseif (!empty($product_info)) {
  708. $this->data['mpn'] = $product_info['mpn'];
  709. } else {
  710. $this->data['mpn'] = '';
  711. }
  712. if (isset($this->request->post['location'])) {
  713. $this->data['location'] = $this->request->post['location'];
  714. } elseif (!empty($product_info)) {
  715. $this->data['location'] = $product_info['location'];
  716. } else {
  717. $this->data['location'] = '';
  718. }
  719. $this->load->model('setting/store');
  720. $this->data['stores'] = $this->model_setting_store->getStores();
  721. if (isset($this->request->post['product_store'])) {
  722. $this->data['product_store'] = $this->request->post['product_store'];
  723. } elseif (isset($this->request->get['product_id'])) {
  724. $this->data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']);
  725. } else {
  726. $this->data['product_store'] = array(0);
  727. }
  728. if (isset($this->request->post['keyword'])) {
  729. $this->data['keyword'] = $this->request->post['keyword'];
  730. } elseif (!empty($product_info)) {
  731. $this->data['keyword'] = $product_info['keyword'];
  732. } else {
  733. $this->data['keyword'] = '';
  734. }
  735. if (isset($this->request->post['image'])) {
  736. $this->data['image'] = $this->request->post['image'];
  737. } elseif (!empty($product_info)) {
  738. $this->data['image'] = $product_info['image'];
  739. } else {
  740. $this->data['image'] = '';
  741. }
  742. $this->load->model('tool/image');
  743. if (isset($this->request->post['image']) && file_exists(DIR_IMAGE . $this->request->post['image'])) {
  744. $this->data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);
  745. } elseif (!empty($product_info) && $product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
  746. $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
  747. } else {
  748. $this->data['thumb'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);
  749. }
  750. if (isset($this->request->post['shipping'])) {
  751. $this->data['shipping'] = $this->request->post['shipping'];
  752. } elseif (!empty($product_info)) {
  753. $this->data['shipping'] = $product_info['shipping'];
  754. } else {
  755. $this->data['shipping'] = 1;
  756. }
  757. if (isset($this->request->post['price'])) {
  758. $this->data['price'] = $this->request->post['price'];
  759. } elseif (!empty($product_info)) {
  760. $this->data['price'] = $product_info['price'];
  761. } else {
  762. $this->data['price'] = '';
  763. }
  764. $this->load->model('localisation/tax_class');
  765. $this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
  766. if (isset($this->request->post['tax_class_id'])) {
  767. $this->data['tax_class_id'] = $this->request->post['tax_class_id'];
  768. } elseif (!empty($product_info)) {
  769. $this->data['tax_class_id'] = $product_info['tax_class_id'];
  770. } else {
  771. $this->data['tax_class_id'] = 0;
  772. }
  773. if (isset($this->request->post['date_available'])) {
  774. $this->data['date_available'] = $this->request->post['date_available'];
  775. } elseif (!empty($product_info)) {
  776. $this->data['date_available'] = date('Y-m-d', strtotime($product_info['date_available']));
  777. } else {
  778. $this->data['date_available'] = date('Y-m-d', time() - 86400);
  779. }
  780. if (isset($this->request->post['quantity'])) {
  781. $this->data['quantity'] = $this->request->post['quantity'];
  782. } elseif (!empty($product_info)) {
  783. $this->data['quantity'] = $product_info['quantity'];
  784. } else {
  785. $this->data['quantity'] = 1;
  786. }
  787. if (isset($this->request->post['minimum'])) {
  788. $this->data['minimum'] = $this->request->post['minimum'];
  789. } elseif (!empty($product_info)) {
  790. $this->data['minimum'] = $product_info['minimum'];
  791. } else {
  792. $this->data['minimum'] = 1;
  793. }
  794. if (isset($this->request->post['subtract'])) {
  795. $this->data['subtract'] = $this->request->post['subtract'];
  796. } elseif (!empty($product_info)) {
  797. $this->data['subtract'] = $product_info['subtract'];
  798. } else {
  799. $this->data['subtract'] = 1;
  800. }
  801. if (isset($this->request->post['sort_order'])) {
  802. $this->data['sort_order'] = $this->request->post['sort_order'];
  803. } elseif (!empty($product_info)) {
  804. $this->data['sort_order'] = $product_info['sort_order'];
  805. } else {
  806. $this->data['sort_order'] = 1;
  807. }
  808. $this->load->model('localisation/stock_status');
  809. $this->data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
  810. if (isset($this->request->post['stock_status_id'])) {
  811. $this->data['stock_status_id'] = $this->request->post['stock_status_id'];
  812. } elseif (!empty($product_info)) {
  813. $this->data['stock_status_id'] = $product_info['stock_status_id'];
  814. } else {
  815. $this->data['stock_status_id'] = $this->config->get('config_stock_status_id');
  816. }
  817. if (isset($this->request->post['status'])) {
  818. $this->data['status'] = $this->request->post['status'];
  819. } elseif (!empty($product_info)) {
  820. $this->data['status'] = $product_info['status'];
  821. } else {
  822. $this->data['status'] = 1;
  823. }
  824. if (isset($this->request->post['weight'])) {
  825. $this->data['weight'] = $this->request->post['weight'];
  826. } elseif (!empty($product_info)) {
  827. $this->data['weight'] = $product_info['weight'];
  828. } else {
  829. $this->data['weight'] = '';
  830. }
  831. $this->load->model('localisation/weight_class');
  832. $this->data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
  833. if (isset($this->request->post['weight_class_id'])) {
  834. $this->data['weight_class_id'] = $this->request->post['weight_class_id'];
  835. } elseif (!empty($product_info)) {
  836. $this->data['weight_class_id'] = $product_info['weight_class_id'];
  837. } else {
  838. $this->data['weight_class_id'] = $this->config->get('config_weight_class_id');
  839. }
  840. if (isset($this->request->post['length'])) {
  841. $this->data['length'] = $this->request->post['length'];
  842. } elseif (!empty($product_info)) {
  843. $this->data['length'] = $product_info['length'];
  844. } else {
  845. $this->data['length'] = '';
  846. }
  847. if (isset($this->request->post['width'])) {
  848. $this->data['width'] = $this->request->post['width'];
  849. } elseif (!empty($product_info)) {
  850. $this->data['width'] = $product_info['width'];
  851. } else {
  852. $this->data['width'] = '';
  853. }
  854. if (isset($this->request->post['height'])) {
  855. $this->data['height'] = $this->request->post['height'];
  856. } elseif (!empty($product_info)) {
  857. $this->data['height'] = $product_info['height'];
  858. } else {
  859. $this->data['height'] = '';
  860. }
  861. $this->load->model('localisation/length_class');
  862. $this->data['length_classes'] = $this->model_localisation_length_class->getLengthClasses();
  863. if (isset($this->request->post['length_class_id'])) {
  864. $this->data['length_class_id'] = $this->request->post['length_class_id'];
  865. } elseif (!empty($product_info)) {
  866. $this->data['length_class_id'] = $product_info['length_class_id'];
  867. } else {
  868. $this->data['length_class_id'] = $this->config->get('config_length_class_id');
  869. }
  870. $this->load->model('catalog/manufacturer');
  871. if (isset($this->request->post['manufacturer_id'])) {
  872. $this->data['manufacturer_id'] = $this->request->post['manufacturer_id'];
  873. } elseif (!empty($product_info)) {
  874. $this->data['manufacturer_id'] = $product_info['manufacturer_id'];
  875. } else {
  876. $this->data['manufacturer_id'] = 0;
  877. }
  878. if (isset($this->request->post['manufacturer'])) {
  879. $this->data['manufacturer'] = $this->request->post['manufacturer'];
  880. } elseif (!empty($product_info)) {
  881. $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
  882. if ($manufacturer_info) {
  883. $this->data['manufacturer'] = $manufacturer_info['name'];
  884. } else {
  885. $this->data['manufacturer'] = '';
  886. }
  887. } else {
  888. $this->data['manufacturer'] = '';
  889. }
  890. // Categories
  891. $this->load->model('catalog/category');
  892. if (isset($this->request->post['product_category'])) {
  893. $categories = $this->request->post['product_category'];
  894. } elseif (isset($this->request->get['product_id'])) {
  895. $categories = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
  896. } else {
  897. $categories = array();
  898. }
  899. $this->data['product_categories'] = array();
  900. foreach ($categories as $category_id) {
  901. $category_info = $this->model_catalog_category->getCategory($category_id);
  902. if ($category_info) {
  903. $this->data['product_categories'][] = array(
  904. 'category_id' => $category_info['category_id'],
  905. 'name' => ($category_info['path'] ? $category_info['path'] . ' &gt; ' : '') . $category_info['name']
  906. );
  907. }
  908. }
  909. // Filters
  910. $this->load->model('catalog/filter');
  911. if (isset($this->request->post['product_filter'])) {
  912. $filters = $this->request->post['product_filter'];
  913. } elseif (isset($this->request->get['product_id'])) {
  914. $filters = $this->model_catalog_product->getProductFilters($this->request->get['product_id']);
  915. } else {
  916. $filters = array();
  917. }
  918. $this->data['product_filters'] = array();
  919. foreach ($filters as $filter_id) {
  920. $filter_info = $this->model_catalog_filter->getFilter($filter_id);
  921. if ($filter_info) {
  922. $this->data['product_filters'][] = array(
  923. 'filter_id' => $filter_info['filter_id'],
  924. 'name' => $filter_info['group'] . ' &gt; ' . $filter_info['name']
  925. );
  926. }
  927. }
  928. // Attributes
  929. $this->load->model('catalog/attribute');
  930. if (isset($this->request->post['product_attribute'])) {
  931. $product_attributes = $this->request->post['product_attribute'];
  932. } elseif (isset($this->request->get['product_id'])) {
  933. $product_attributes = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
  934. } else {
  935. $product_attributes = array();
  936. }
  937. $this->data['product_attributes'] = array();
  938. foreach ($product_attributes as $product_attribute) {
  939. $attribute_info = $this->model_catalog_attribute->getAttribute($product_attribute['attribute_id']);
  940. if ($attribute_info) {
  941. $this->data['product_attributes'][] = array(
  942. 'attribute_id' => $product_attribute['attribute_id'],
  943. 'name' => $attribute_info['name'],
  944. 'product_attribute_description' => $product_attribute['product_attribute_description']
  945. );
  946. }
  947. }
  948. // Options
  949. $this->load->model('catalog/option');
  950. if (isset($this->request->post['product_option'])) {
  951. $product_options = $this->request->post['product_option'];
  952. } elseif (isset($this->request->get['product_id'])) {
  953. $product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']);
  954. } else {
  955. $product_options = array();
  956. }
  957. $this->data['product_options'] = array();
  958. foreach ($product_options as $product_option) {
  959. if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
  960. $product_option_value_data = array();
  961. foreach ($product_option['product_option_value'] as $product_option_value) {
  962. $product_option_value_data[] = array(
  963. 'product_option_value_id' => $product_option_value['product_option_value_id'],
  964. 'option_value_id' => $product_option_value['option_value_id'],
  965. 'quantity' => $product_option_value['quantity'],
  966. 'subtract' => $product_option_value['subtract'],
  967. 'price' => $product_option_value['price'],
  968. 'price_prefix' => $product_option_value['price_prefix'],
  969. 'points' => $product_option_value['points'],
  970. 'points_prefix' => $product_option_value['points_prefix'],
  971. 'weight' => $product_option_value['weight'],
  972. 'weight_prefix' => $product_option_value['weight_prefix']
  973. );
  974. }
  975. $this->data['product_options'][] = array(
  976. 'product_option_id' => $product_option['product_option_id'],
  977. 'product_option_value' => $product_option_value_data,
  978. 'option_id' => $product_option['option_id'],
  979. 'name' => $product_option['name'],
  980. 'type' => $product_option['type'],
  981. 'required' => $product_option['required']
  982. );
  983. } else {
  984. $this->data['product_options'][] = array(
  985. 'product_option_id' => $product_option['product_option_id'],
  986. 'option_id' => $product_option['option_id'],
  987. 'name' => $product_option['name'],
  988. 'type' => $product_option['type'],
  989. 'option_value' => $product_option['option_value'],
  990. 'required' => $product_option['required']
  991. );
  992. }
  993. }
  994. $this->data['option_values'] = array();
  995. foreach ($this->data['product_options'] as $product_option) {
  996. if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
  997. if (!isset($this->data['option_values'][$product_option['option_id']])) {
  998. $this->data['option_values'][$product_option['option_id']] = $this->model_catalog_option->getOptionValues($product_option['option_id']);
  999. }
  1000. }
  1001. }
  1002. $this->load->model('sale/customer_group');
  1003. $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
  1004. if (isset($this->request->post['product_discount'])) {
  1005. $this->data['product_discounts'] = $this->request->post['product_discount'];
  1006. } elseif (isset($this->request->get['product_id'])) {
  1007. $this->data['product_discounts'] = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
  1008. } else {
  1009. $this->data['product_discounts'] = array();
  1010. }
  1011. if (isset($this->request->post['product_special'])) {
  1012. $this->data['product_specials'] = $this->request->post['product_special'];
  1013. } elseif (isset($this->request->get['product_id'])) {
  1014. $this->data['product_specials'] = $this->model_catalog_product->getProductSpecials($this->request->get['product_id']);
  1015. } else {
  1016. $this->data['product_specials'] = array();
  1017. }
  1018. // Images
  1019. if (isset($this->request->post['product_image'])) {
  1020. $product_images = $this->request->post['product_image'];
  1021. } elseif (isset($this->request->get['product_id'])) {
  1022. $product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
  1023. } else {
  1024. $product_images = array();
  1025. }
  1026. $this->data['product_images'] = array();
  1027. foreach ($product_images as $product_image) {
  1028. if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) {
  1029. $image = $product_image['image'];
  1030. } else {
  1031. $image = 'no_image.jpg';
  1032. }
  1033. $this->data['product_images'][] = array(
  1034. 'ima