shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

product.php (46585B)


      1 <?php
      2 class ControllerCatalogProduct extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('catalog/product');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('catalog/product');
     11 
     12 		$this->getList();
     13 	}
     14 
     15 	public function add() {
     16 		$this->load->language('catalog/product');
     17 
     18 		$this->document->setTitle($this->language->get('heading_title'));
     19 
     20 		$this->load->model('catalog/product');
     21 
     22 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
     23 			$this->model_catalog_product->addProduct($this->request->post);
     24 
     25 			$this->session->data['success'] = $this->language->get('text_success');
     26 
     27 			$url = '';
     28 
     29 			if (isset($this->request->get['filter_name'])) {
     30 				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
     31 			}
     32 
     33 			if (isset($this->request->get['filter_model'])) {
     34 				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
     35 			}
     36 
     37 			if (isset($this->request->get['filter_price'])) {
     38 				$url .= '&filter_price=' . $this->request->get['filter_price'];
     39 			}
     40 
     41 			if (isset($this->request->get['filter_quantity'])) {
     42 				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
     43 			}
     44 
     45 			if (isset($this->request->get['filter_status'])) {
     46 				$url .= '&filter_status=' . $this->request->get['filter_status'];
     47 			}
     48 
     49 			if (isset($this->request->get['sort'])) {
     50 				$url .= '&sort=' . $this->request->get['sort'];
     51 			}
     52 
     53 			if (isset($this->request->get['order'])) {
     54 				$url .= '&order=' . $this->request->get['order'];
     55 			}
     56 
     57 			if (isset($this->request->get['page'])) {
     58 				$url .= '&page=' . $this->request->get['page'];
     59 			}
     60 
     61 			$this->response->redirect($this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true));
     62 		}
     63 
     64 		$this->getForm();
     65 	}
     66 
     67 	public function edit() {
     68 		$this->load->language('catalog/product');
     69 
     70 		$this->document->setTitle($this->language->get('heading_title'));
     71 
     72 		$this->load->model('catalog/product');
     73 
     74 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
     75 			$this->model_catalog_product->editProduct($this->request->get['product_id'], $this->request->post);
     76 
     77 			$this->session->data['success'] = $this->language->get('text_success');
     78 
     79 			$url = '';
     80 
     81 			if (isset($this->request->get['filter_name'])) {
     82 				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
     83 			}
     84 
     85 			if (isset($this->request->get['filter_model'])) {
     86 				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
     87 			}
     88 
     89 			if (isset($this->request->get['filter_price'])) {
     90 				$url .= '&filter_price=' . $this->request->get['filter_price'];
     91 			}
     92 
     93 			if (isset($this->request->get['filter_quantity'])) {
     94 				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
     95 			}
     96 
     97 			if (isset($this->request->get['filter_status'])) {
     98 				$url .= '&filter_status=' . $this->request->get['filter_status'];
     99 			}
    100 
    101 			if (isset($this->request->get['sort'])) {
    102 				$url .= '&sort=' . $this->request->get['sort'];
    103 			}
    104 
    105 			if (isset($this->request->get['order'])) {
    106 				$url .= '&order=' . $this->request->get['order'];
    107 			}
    108 
    109 			if (isset($this->request->get['page'])) {
    110 				$url .= '&page=' . $this->request->get['page'];
    111 			}
    112 
    113 			$this->response->redirect($this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true));
    114 		}
    115 
    116 		$this->getForm();
    117 	}
    118 
    119 	public function delete() {
    120 		$this->load->language('catalog/product');
    121 
    122 		$this->document->setTitle($this->language->get('heading_title'));
    123 
    124 		$this->load->model('catalog/product');
    125 
    126 		if (isset($this->request->post['selected']) && $this->validateDelete()) {
    127 			foreach ($this->request->post['selected'] as $product_id) {
    128 				$this->model_catalog_product->deleteProduct($product_id);
    129 			}
    130 
    131 			$this->session->data['success'] = $this->language->get('text_success');
    132 
    133 			$url = '';
    134 
    135 			if (isset($this->request->get['filter_name'])) {
    136 				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    137 			}
    138 
    139 			if (isset($this->request->get['filter_model'])) {
    140 				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    141 			}
    142 
    143 			if (isset($this->request->get['filter_price'])) {
    144 				$url .= '&filter_price=' . $this->request->get['filter_price'];
    145 			}
    146 
    147 			if (isset($this->request->get['filter_quantity'])) {
    148 				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    149 			}
    150 
    151 			if (isset($this->request->get['filter_status'])) {
    152 				$url .= '&filter_status=' . $this->request->get['filter_status'];
    153 			}
    154 
    155 			if (isset($this->request->get['sort'])) {
    156 				$url .= '&sort=' . $this->request->get['sort'];
    157 			}
    158 
    159 			if (isset($this->request->get['order'])) {
    160 				$url .= '&order=' . $this->request->get['order'];
    161 			}
    162 
    163 			if (isset($this->request->get['page'])) {
    164 				$url .= '&page=' . $this->request->get['page'];
    165 			}
    166 
    167 			$this->response->redirect($this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true));
    168 		}
    169 
    170 		$this->getList();
    171 	}
    172 
    173 	public function copy() {
    174 		$this->load->language('catalog/product');
    175 
    176 		$this->document->setTitle($this->language->get('heading_title'));
    177 
    178 		$this->load->model('catalog/product');
    179 
    180 		if (isset($this->request->post['selected']) && $this->validateCopy()) {
    181 			foreach ($this->request->post['selected'] as $product_id) {
    182 				$this->model_catalog_product->copyProduct($product_id);
    183 			}
    184 
    185 			$this->session->data['success'] = $this->language->get('text_success');
    186 
    187 			$url = '';
    188 
    189 			if (isset($this->request->get['filter_name'])) {
    190 				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    191 			}
    192 
    193 			if (isset($this->request->get['filter_model'])) {
    194 				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    195 			}
    196 
    197 			if (isset($this->request->get['filter_price'])) {
    198 				$url .= '&filter_price=' . $this->request->get['filter_price'];
    199 			}
    200 
    201 			if (isset($this->request->get['filter_quantity'])) {
    202 				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    203 			}
    204 
    205 			if (isset($this->request->get['filter_status'])) {
    206 				$url .= '&filter_status=' . $this->request->get['filter_status'];
    207 			}
    208 
    209 			if (isset($this->request->get['sort'])) {
    210 				$url .= '&sort=' . $this->request->get['sort'];
    211 			}
    212 
    213 			if (isset($this->request->get['order'])) {
    214 				$url .= '&order=' . $this->request->get['order'];
    215 			}
    216 
    217 			if (isset($this->request->get['page'])) {
    218 				$url .= '&page=' . $this->request->get['page'];
    219 			}
    220 
    221 			$this->response->redirect($this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true));
    222 		}
    223 
    224 		$this->getList();
    225 	}
    226 
    227 	protected function getList() {
    228 		if (isset($this->request->get['filter_name'])) {
    229 			$filter_name = $this->request->get['filter_name'];
    230 		} else {
    231 			$filter_name = '';
    232 		}
    233 
    234 		if (isset($this->request->get['filter_model'])) {
    235 			$filter_model = $this->request->get['filter_model'];
    236 		} else {
    237 			$filter_model = '';
    238 		}
    239 
    240 		if (isset($this->request->get['filter_price'])) {
    241 			$filter_price = $this->request->get['filter_price'];
    242 		} else {
    243 			$filter_price = '';
    244 		}
    245 
    246 		if (isset($this->request->get['filter_quantity'])) {
    247 			$filter_quantity = $this->request->get['filter_quantity'];
    248 		} else {
    249 			$filter_quantity = '';
    250 		}
    251 
    252 		if (isset($this->request->get['filter_status'])) {
    253 			$filter_status = $this->request->get['filter_status'];
    254 		} else {
    255 			$filter_status = '';
    256 		}
    257 
    258 		if (isset($this->request->get['sort'])) {
    259 			$sort = $this->request->get['sort'];
    260 		} else {
    261 			$sort = 'pd.name';
    262 		}
    263 
    264 		if (isset($this->request->get['order'])) {
    265 			$order = $this->request->get['order'];
    266 		} else {
    267 			$order = 'ASC';
    268 		}
    269 
    270 		if (isset($this->request->get['page'])) {
    271 			$page = $this->request->get['page'];
    272 		} else {
    273 			$page = 1;
    274 		}
    275 
    276 		$url = '';
    277 
    278 		if (isset($this->request->get['filter_name'])) {
    279 			$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    280 		}
    281 
    282 		if (isset($this->request->get['filter_model'])) {
    283 			$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    284 		}
    285 
    286 		if (isset($this->request->get['filter_price'])) {
    287 			$url .= '&filter_price=' . $this->request->get['filter_price'];
    288 		}
    289 
    290 		if (isset($this->request->get['filter_quantity'])) {
    291 			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    292 		}
    293 
    294 		if (isset($this->request->get['filter_status'])) {
    295 			$url .= '&filter_status=' . $this->request->get['filter_status'];
    296 		}
    297 
    298 		if (isset($this->request->get['order'])) {
    299 			$url .= '&order=' . $this->request->get['order'];
    300 		}
    301 
    302 		if (isset($this->request->get['page'])) {
    303 			$url .= '&page=' . $this->request->get['page'];
    304 		}
    305 
    306 		$data['breadcrumbs'] = array();
    307 
    308 		$data['breadcrumbs'][] = array(
    309 			'text' => $this->language->get('text_home'),
    310 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
    311 		);
    312 
    313 		$data['breadcrumbs'][] = array(
    314 			'text' => $this->language->get('heading_title'),
    315 			'href' => $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true)
    316 		);
    317 
    318 		$data['add'] = $this->url->link('catalog/product/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
    319 		$data['copy'] = $this->url->link('catalog/product/copy', 'user_token=' . $this->session->data['user_token'] . $url, true);
    320 		$data['delete'] = $this->url->link('catalog/product/delete', 'user_token=' . $this->session->data['user_token'] . $url, true);
    321 
    322 		$data['products'] = array();
    323 
    324 		$filter_data = array(
    325 			'filter_name'	  => $filter_name,
    326 			'filter_model'	  => $filter_model,
    327 			'filter_price'	  => $filter_price,
    328 			'filter_quantity' => $filter_quantity,
    329 			'filter_status'   => $filter_status,
    330 			'sort'            => $sort,
    331 			'order'           => $order,
    332 			'start'           => ($page - 1) * $this->config->get('config_limit_admin'),
    333 			'limit'           => $this->config->get('config_limit_admin')
    334 		);
    335 
    336 		$this->load->model('tool/image');
    337 
    338 		$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
    339 
    340 		$results = $this->model_catalog_product->getProducts($filter_data);
    341 
    342 		foreach ($results as $result) {
    343 			if (is_file(DIR_IMAGE . $result['image'])) {
    344 				$image = $this->model_tool_image->resize($result['image'], 40, 40);
    345 			} else {
    346 				$image = $this->model_tool_image->resize('no_image.png', 40, 40);
    347 			}
    348 
    349 			$special = false;
    350 
    351 			$product_specials = $this->model_catalog_product->getProductSpecials($result['product_id']);
    352 
    353 			foreach ($product_specials  as $product_special) {
    354 				if (($product_special['date_start'] == '0000-00-00' || strtotime($product_special['date_start']) < time()) && ($product_special['date_end'] == '0000-00-00' || strtotime($product_special['date_end']) > time())) {
    355 					$special = $this->currency->format($product_special['price'], $this->config->get('config_currency'));
    356 
    357 					break;
    358 				}
    359 			}
    360 
    361 			$data['products'][] = array(
    362 				'product_id' => $result['product_id'],
    363 				'image'      => $image,
    364 				'name'       => $result['name'],
    365 				'model'      => $result['model'],
    366 				'price'      => $this->currency->format($result['price'], $this->config->get('config_currency')),
    367 				'special'    => $special,
    368 				'quantity'   => $result['quantity'],
    369 				'status'     => $result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled'),
    370 				'edit'       => $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $result['product_id'] . $url, true)
    371 			);
    372 		}
    373 
    374 		$data['user_token'] = $this->session->data['user_token'];
    375 
    376 		if (isset($this->error['warning'])) {
    377 			$data['error_warning'] = $this->error['warning'];
    378 		} else {
    379 			$data['error_warning'] = '';
    380 		}
    381 
    382 		if (isset($this->session->data['success'])) {
    383 			$data['success'] = $this->session->data['success'];
    384 
    385 			unset($this->session->data['success']);
    386 		} else {
    387 			$data['success'] = '';
    388 		}
    389 
    390 		if (isset($this->request->post['selected'])) {
    391 			$data['selected'] = (array)$this->request->post['selected'];
    392 		} else {
    393 			$data['selected'] = array();
    394 		}
    395 
    396 		$url = '';
    397 
    398 		if (isset($this->request->get['filter_name'])) {
    399 			$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    400 		}
    401 
    402 		if (isset($this->request->get['filter_model'])) {
    403 			$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    404 		}
    405 
    406 		if (isset($this->request->get['filter_price'])) {
    407 			$url .= '&filter_price=' . $this->request->get['filter_price'];
    408 		}
    409 
    410 		if (isset($this->request->get['filter_quantity'])) {
    411 			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    412 		}
    413 
    414 		if (isset($this->request->get['filter_status'])) {
    415 			$url .= '&filter_status=' . $this->request->get['filter_status'];
    416 		}
    417 
    418 		if ($order == 'ASC') {
    419 			$url .= '&order=DESC';
    420 		} else {
    421 			$url .= '&order=ASC';
    422 		}
    423 
    424 		if (isset($this->request->get['page'])) {
    425 			$url .= '&page=' . $this->request->get['page'];
    426 		}
    427 
    428 		$data['sort_name'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=pd.name' . $url, true);
    429 		$data['sort_model'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.model' . $url, true);
    430 		$data['sort_price'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.price' . $url, true);
    431 		$data['sort_quantity'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.quantity' . $url, true);
    432 		$data['sort_status'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.status' . $url, true);
    433 		$data['sort_order'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . '&sort=p.sort_order' . $url, true);
    434 
    435 		$url = '';
    436 
    437 		if (isset($this->request->get['filter_name'])) {
    438 			$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    439 		}
    440 
    441 		if (isset($this->request->get['filter_model'])) {
    442 			$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    443 		}
    444 
    445 		if (isset($this->request->get['filter_price'])) {
    446 			$url .= '&filter_price=' . $this->request->get['filter_price'];
    447 		}
    448 
    449 		if (isset($this->request->get['filter_quantity'])) {
    450 			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    451 		}
    452 
    453 		if (isset($this->request->get['filter_status'])) {
    454 			$url .= '&filter_status=' . $this->request->get['filter_status'];
    455 		}
    456 
    457 		if (isset($this->request->get['sort'])) {
    458 			$url .= '&sort=' . $this->request->get['sort'];
    459 		}
    460 
    461 		if (isset($this->request->get['order'])) {
    462 			$url .= '&order=' . $this->request->get['order'];
    463 		}
    464 
    465 		$pagination = new Pagination();
    466 		$pagination->total = $product_total;
    467 		$pagination->page = $page;
    468 		$pagination->limit = $this->config->get('config_limit_admin');
    469 		$pagination->url = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);
    470 
    471 		$data['pagination'] = $pagination->render();
    472 
    473 		$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($product_total - $this->config->get('config_limit_admin'))) ? $product_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $product_total, ceil($product_total / $this->config->get('config_limit_admin')));
    474 
    475 		$data['filter_name'] = $filter_name;
    476 		$data['filter_model'] = $filter_model;
    477 		$data['filter_price'] = $filter_price;
    478 		$data['filter_quantity'] = $filter_quantity;
    479 		$data['filter_status'] = $filter_status;
    480 
    481 		$data['sort'] = $sort;
    482 		$data['order'] = $order;
    483 
    484 		$data['header'] = $this->load->controller('common/header');
    485 		$data['column_left'] = $this->load->controller('common/column_left');
    486 		$data['footer'] = $this->load->controller('common/footer');
    487 
    488 		$this->response->setOutput($this->load->view('catalog/product_list', $data));
    489 	}
    490 
    491 	protected function getForm() {
    492 		$data['text_form'] = !isset($this->request->get['product_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
    493 
    494 		if (isset($this->error['warning'])) {
    495 			$data['error_warning'] = $this->error['warning'];
    496 		} else {
    497 			$data['error_warning'] = '';
    498 		}
    499 
    500 		if (isset($this->error['name'])) {
    501 			$data['error_name'] = $this->error['name'];
    502 		} else {
    503 			$data['error_name'] = array();
    504 		}
    505 
    506 		if (isset($this->error['meta_title'])) {
    507 			$data['error_meta_title'] = $this->error['meta_title'];
    508 		} else {
    509 			$data['error_meta_title'] = array();
    510 		}
    511 
    512 		if (isset($this->error['model'])) {
    513 			$data['error_model'] = $this->error['model'];
    514 		} else {
    515 			$data['error_model'] = '';
    516 		}
    517 
    518 		if (isset($this->error['keyword'])) {
    519 			$data['error_keyword'] = $this->error['keyword'];
    520 		} else {
    521 			$data['error_keyword'] = '';
    522 		}
    523 
    524 		$url = '';
    525 
    526 		if (isset($this->request->get['filter_name'])) {
    527 			$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
    528 		}
    529 
    530 		if (isset($this->request->get['filter_model'])) {
    531 			$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
    532 		}
    533 
    534 		if (isset($this->request->get['filter_price'])) {
    535 			$url .= '&filter_price=' . $this->request->get['filter_price'];
    536 		}
    537 
    538 		if (isset($this->request->get['filter_quantity'])) {
    539 			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
    540 		}
    541 
    542 		if (isset($this->request->get['filter_status'])) {
    543 			$url .= '&filter_status=' . $this->request->get['filter_status'];
    544 		}
    545 
    546 		if (isset($this->request->get['sort'])) {
    547 			$url .= '&sort=' . $this->request->get['sort'];
    548 		}
    549 
    550 		if (isset($this->request->get['order'])) {
    551 			$url .= '&order=' . $this->request->get['order'];
    552 		}
    553 
    554 		if (isset($this->request->get['page'])) {
    555 			$url .= '&page=' . $this->request->get['page'];
    556 		}
    557 
    558 		$data['breadcrumbs'] = array();
    559 
    560 		$data['breadcrumbs'][] = array(
    561 			'text' => $this->language->get('text_home'),
    562 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
    563 		);
    564 
    565 		$data['breadcrumbs'][] = array(
    566 			'text' => $this->language->get('heading_title'),
    567 			'href' => $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true)
    568 		);
    569 
    570 		if (!isset($this->request->get['product_id'])) {
    571 			$data['action'] = $this->url->link('catalog/product/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
    572 		} else {
    573 			$data['action'] = $this->url->link('catalog/product/edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $this->request->get['product_id'] . $url, true);
    574 		}
    575 
    576 		$data['cancel'] = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'] . $url, true);
    577 
    578 		if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
    579 			$product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
    580 		}
    581 
    582 		$data['user_token'] = $this->session->data['user_token'];
    583 
    584 		$this->load->model('localisation/language');
    585 
    586 		$data['languages'] = $this->model_localisation_language->getLanguages();
    587 
    588 		if (isset($this->request->post['product_description'])) {
    589 			$data['product_description'] = $this->request->post['product_description'];
    590 		} elseif (isset($this->request->get['product_id'])) {
    591 			$data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
    592 		} else {
    593 			$data['product_description'] = array();
    594 		}
    595 
    596 		if (isset($this->request->post['model'])) {
    597 			$data['model'] = $this->request->post['model'];
    598 		} elseif (!empty($product_info)) {
    599 			$data['model'] = $product_info['model'];
    600 		} else {
    601 			$data['model'] = '';
    602 		}
    603 
    604 		if (isset($this->request->post['sku'])) {
    605 			$data['sku'] = $this->request->post['sku'];
    606 		} elseif (!empty($product_info)) {
    607 			$data['sku'] = $product_info['sku'];
    608 		} else {
    609 			$data['sku'] = '';
    610 		}
    611 
    612 		if (isset($this->request->post['upc'])) {
    613 			$data['upc'] = $this->request->post['upc'];
    614 		} elseif (!empty($product_info)) {
    615 			$data['upc'] = $product_info['upc'];
    616 		} else {
    617 			$data['upc'] = '';
    618 		}
    619 
    620 		if (isset($this->request->post['ean'])) {
    621 			$data['ean'] = $this->request->post['ean'];
    622 		} elseif (!empty($product_info)) {
    623 			$data['ean'] = $product_info['ean'];
    624 		} else {
    625 			$data['ean'] = '';
    626 		}
    627 
    628 		if (isset($this->request->post['jan'])) {
    629 			$data['jan'] = $this->request->post['jan'];
    630 		} elseif (!empty($product_info)) {
    631 			$data['jan'] = $product_info['jan'];
    632 		} else {
    633 			$data['jan'] = '';
    634 		}
    635 
    636 		if (isset($this->request->post['isbn'])) {
    637 			$data['isbn'] = $this->request->post['isbn'];
    638 		} elseif (!empty($product_info)) {
    639 			$data['isbn'] = $product_info['isbn'];
    640 		} else {
    641 			$data['isbn'] = '';
    642 		}
    643 
    644 		if (isset($this->request->post['mpn'])) {
    645 			$data['mpn'] = $this->request->post['mpn'];
    646 		} elseif (!empty($product_info)) {
    647 			$data['mpn'] = $product_info['mpn'];
    648 		} else {
    649 			$data['mpn'] = '';
    650 		}
    651 
    652 		if (isset($this->request->post['location'])) {
    653 			$data['location'] = $this->request->post['location'];
    654 		} elseif (!empty($product_info)) {
    655 			$data['location'] = $product_info['location'];
    656 		} else {
    657 			$data['location'] = '';
    658 		}
    659 
    660 		$this->load->model('setting/store');
    661 
    662 		$data['stores'] = array();
    663 		
    664 		$data['stores'][] = array(
    665 			'store_id' => 0,
    666 			'name'     => $this->language->get('text_default')
    667 		);
    668 		
    669 		$stores = $this->model_setting_store->getStores();
    670 
    671 		foreach ($stores as $store) {
    672 			$data['stores'][] = array(
    673 				'store_id' => $store['store_id'],
    674 				'name'     => $store['name']
    675 			);
    676 		}
    677 
    678 		if (isset($this->request->post['product_store'])) {
    679 			$data['product_store'] = $this->request->post['product_store'];
    680 		} elseif (isset($this->request->get['product_id'])) {
    681 			$data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']);
    682 		} else {
    683 			$data['product_store'] = array(0);
    684 		}
    685 
    686 		if (isset($this->request->post['shipping'])) {
    687 			$data['shipping'] = $this->request->post['shipping'];
    688 		} elseif (!empty($product_info)) {
    689 			$data['shipping'] = $product_info['shipping'];
    690 		} else {
    691 			$data['shipping'] = 1;
    692 		}
    693 
    694 		if (isset($this->request->post['price'])) {
    695 			$data['price'] = $this->request->post['price'];
    696 		} elseif (!empty($product_info)) {
    697 			$data['price'] = $product_info['price'];
    698 		} else {
    699 			$data['price'] = '';
    700 		}
    701 
    702 		$this->load->model('catalog/recurring');
    703 
    704 		$data['recurrings'] = $this->model_catalog_recurring->getRecurrings();
    705 
    706 		if (isset($this->request->post['product_recurrings'])) {
    707 			$data['product_recurrings'] = $this->request->post['product_recurrings'];
    708 		} elseif (!empty($product_info)) {
    709 			$data['product_recurrings'] = $this->model_catalog_product->getRecurrings($product_info['product_id']);
    710 		} else {
    711 			$data['product_recurrings'] = array();
    712 		}
    713 
    714 		$this->load->model('localisation/tax_class');
    715 
    716 		$data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
    717 
    718 		if (isset($this->request->post['tax_class_id'])) {
    719 			$data['tax_class_id'] = $this->request->post['tax_class_id'];
    720 		} elseif (!empty($product_info)) {
    721 			$data['tax_class_id'] = $product_info['tax_class_id'];
    722 		} else {
    723 			$data['tax_class_id'] = 0;
    724 		}
    725 
    726 		if (isset($this->request->post['date_available'])) {
    727 			$data['date_available'] = $this->request->post['date_available'];
    728 		} elseif (!empty($product_info)) {
    729 			$data['date_available'] = ($product_info['date_available'] != '0000-00-00') ? $product_info['date_available'] : '';
    730 		} else {
    731 			$data['date_available'] = date('Y-m-d');
    732 		}
    733 
    734 		if (isset($this->request->post['quantity'])) {
    735 			$data['quantity'] = $this->request->post['quantity'];
    736 		} elseif (!empty($product_info)) {
    737 			$data['quantity'] = $product_info['quantity'];
    738 		} else {
    739 			$data['quantity'] = 1;
    740 		}
    741 
    742 		if (isset($this->request->post['minimum'])) {
    743 			$data['minimum'] = $this->request->post['minimum'];
    744 		} elseif (!empty($product_info)) {
    745 			$data['minimum'] = $product_info['minimum'];
    746 		} else {
    747 			$data['minimum'] = 1;
    748 		}
    749 
    750 		if (isset($this->request->post['subtract'])) {
    751 			$data['subtract'] = $this->request->post['subtract'];
    752 		} elseif (!empty($product_info)) {
    753 			$data['subtract'] = $product_info['subtract'];
    754 		} else {
    755 			$data['subtract'] = 1;
    756 		}
    757 
    758 		if (isset($this->request->post['sort_order'])) {
    759 			$data['sort_order'] = $this->request->post['sort_order'];
    760 		} elseif (!empty($product_info)) {
    761 			$data['sort_order'] = $product_info['sort_order'];
    762 		} else {
    763 			$data['sort_order'] = 1;
    764 		}
    765 
    766 		$this->load->model('localisation/stock_status');
    767 
    768 		$data['stock_statuses'] = $this->model_localisation_stock_status->getStockStatuses();
    769 
    770 		if (isset($this->request->post['stock_status_id'])) {
    771 			$data['stock_status_id'] = $this->request->post['stock_status_id'];
    772 		} elseif (!empty($product_info)) {
    773 			$data['stock_status_id'] = $product_info['stock_status_id'];
    774 		} else {
    775 			$data['stock_status_id'] = 0;
    776 		}
    777 
    778 		if (isset($this->request->post['status'])) {
    779 			$data['status'] = $this->request->post['status'];
    780 		} elseif (!empty($product_info)) {
    781 			$data['status'] = $product_info['status'];
    782 		} else {
    783 			$data['status'] = true;
    784 		}
    785 
    786 		if (isset($this->request->post['weight'])) {
    787 			$data['weight'] = $this->request->post['weight'];
    788 		} elseif (!empty($product_info)) {
    789 			$data['weight'] = $product_info['weight'];
    790 		} else {
    791 			$data['weight'] = '';
    792 		}
    793 
    794 		$this->load->model('localisation/weight_class');
    795 
    796 		$data['weight_classes'] = $this->model_localisation_weight_class->getWeightClasses();
    797 
    798 		if (isset($this->request->post['weight_class_id'])) {
    799 			$data['weight_class_id'] = $this->request->post['weight_class_id'];
    800 		} elseif (!empty($product_info)) {
    801 			$data['weight_class_id'] = $product_info['weight_class_id'];
    802 		} else {
    803 			$data['weight_class_id'] = $this->config->get('config_weight_class_id');
    804 		}
    805 
    806 		if (isset($this->request->post['length'])) {
    807 			$data['length'] = $this->request->post['length'];
    808 		} elseif (!empty($product_info)) {
    809 			$data['length'] = $product_info['length'];
    810 		} else {
    811 			$data['length'] = '';
    812 		}
    813 
    814 		if (isset($this->request->post['width'])) {
    815 			$data['width'] = $this->request->post['width'];
    816 		} elseif (!empty($product_info)) {
    817 			$data['width'] = $product_info['width'];
    818 		} else {
    819 			$data['width'] = '';
    820 		}
    821 
    822 		if (isset($this->request->post['height'])) {
    823 			$data['height'] = $this->request->post['height'];
    824 		} elseif (!empty($product_info)) {
    825 			$data['height'] = $product_info['height'];
    826 		} else {
    827 			$data['height'] = '';
    828 		}
    829 
    830 		$this->load->model('localisation/length_class');
    831 
    832 		$data['length_classes'] = $this->model_localisation_length_class->getLengthClasses();
    833 
    834 		if (isset($this->request->post['length_class_id'])) {
    835 			$data['length_class_id'] = $this->request->post['length_class_id'];
    836 		} elseif (!empty($product_info)) {
    837 			$data['length_class_id'] = $product_info['length_class_id'];
    838 		} else {
    839 			$data['length_class_id'] = $this->config->get('config_length_class_id');
    840 		}
    841 
    842 		$this->load->model('catalog/manufacturer');
    843 
    844 		if (isset($this->request->post['manufacturer_id'])) {
    845 			$data['manufacturer_id'] = $this->request->post['manufacturer_id'];
    846 		} elseif (!empty($product_info)) {
    847 			$data['manufacturer_id'] = $product_info['manufacturer_id'];
    848 		} else {
    849 			$data['manufacturer_id'] = 0;
    850 		}
    851 
    852 		if (isset($this->request->post['manufacturer'])) {
    853 			$data['manufacturer'] = $this->request->post['manufacturer'];
    854 		} elseif (!empty($product_info)) {
    855 			$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
    856 
    857 			if ($manufacturer_info) {
    858 				$data['manufacturer'] = $manufacturer_info['name'];
    859 			} else {
    860 				$data['manufacturer'] = '';
    861 			}
    862 		} else {
    863 			$data['manufacturer'] = '';
    864 		}
    865 
    866 		// Categories
    867 		$this->load->model('catalog/category');
    868 
    869 		if (isset($this->request->post['product_category'])) {
    870 			$categories = $this->request->post['product_category'];
    871 		} elseif (isset($this->request->get['product_id'])) {
    872 			$categories = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
    873 		} else {
    874 			$categories = array();
    875 		}
    876 
    877 		$data['product_categories'] = array();
    878 
    879 		foreach ($categories as $category_id) {
    880 			$category_info = $this->model_catalog_category->getCategory($category_id);
    881 
    882 			if ($category_info) {
    883 				$data['product_categories'][] = array(
    884 					'category_id' => $category_info['category_id'],
    885 					'name'        => ($category_info['path']) ? $category_info['path'] . ' &gt; ' . $category_info['name'] : $category_info['name']
    886 				);
    887 			}
    888 		}
    889 
    890 		// Filters
    891 		$this->load->model('catalog/filter');
    892 
    893 		if (isset($this->request->post['product_filter'])) {
    894 			$filters = $this->request->post['product_filter'];
    895 		} elseif (isset($this->request->get['product_id'])) {
    896 			$filters = $this->model_catalog_product->getProductFilters($this->request->get['product_id']);
    897 		} else {
    898 			$filters = array();
    899 		}
    900 
    901 		$data['product_filters'] = array();
    902 
    903 		foreach ($filters as $filter_id) {
    904 			$filter_info = $this->model_catalog_filter->getFilter($filter_id);
    905 
    906 			if ($filter_info) {
    907 				$data['product_filters'][] = array(
    908 					'filter_id' => $filter_info['filter_id'],
    909 					'name'      => $filter_info['group'] . ' &gt; ' . $filter_info['name']
    910 				);
    911 			}
    912 		}
    913 
    914 		// Attributes
    915 		$this->load->model('catalog/attribute');
    916 
    917 		if (isset($this->request->post['product_attribute'])) {
    918 			$product_attributes = $this->request->post['product_attribute'];
    919 		} elseif (isset($this->request->get['product_id'])) {
    920 			$product_attributes = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
    921 		} else {
    922 			$product_attributes = array();
    923 		}
    924 
    925 		$data['product_attributes'] = array();
    926 
    927 		foreach ($product_attributes as $product_attribute) {
    928 			$attribute_info = $this->model_catalog_attribute->getAttribute($product_attribute['attribute_id']);
    929 
    930 			if ($attribute_info) {
    931 				$data['product_attributes'][] = array(
    932 					'attribute_id'                  => $product_attribute['attribute_id'],
    933 					'name'                          => $attribute_info['name'],
    934 					'product_attribute_description' => $product_attribute['product_attribute_description']
    935 				);
    936 			}
    937 		}
    938 
    939 		// Options
    940 		$this->load->model('catalog/option');
    941 
    942 		if (isset($this->request->post['product_option'])) {
    943 			$product_options = $this->request->post['product_option'];
    944 		} elseif (isset($this->request->get['product_id'])) {
    945 			$product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']);
    946 		} else {
    947 			$product_options = array();
    948 		}
    949 
    950 		$data['product_options'] = array();
    951 
    952 		foreach ($product_options as $product_option) {
    953 			$product_option_value_data = array();
    954 
    955 			if (isset($product_option['product_option_value'])) {
    956 				foreach ($product_option['product_option_value'] as $product_option_value) {
    957 					$product_option_value_data[] = array(
    958 						'product_option_value_id' => $product_option_value['product_option_value_id'],
    959 						'option_value_id'         => $product_option_value['option_value_id'],
    960 						'quantity'                => $product_option_value['quantity'],
    961 						'subtract'                => $product_option_value['subtract'],
    962 						'price'                   => $product_option_value['price'],
    963 						'price_prefix'            => $product_option_value['price_prefix'],
    964 						'points'                  => $product_option_value['points'],
    965 						'points_prefix'           => $product_option_value['points_prefix'],
    966 						'weight'                  => $product_option_value['weight'],
    967 						'weight_prefix'           => $product_option_value['weight_prefix']
    968 					);
    969 				}
    970 			}
    971 
    972 			$data['product_options'][] = array(
    973 				'product_option_id'    => $product_option['product_option_id'],
    974 				'product_option_value' => $product_option_value_data,
    975 				'option_id'            => $product_option['option_id'],
    976 				'name'                 => $product_option['name'],
    977 				'type'                 => $product_option['type'],
    978 				'value'                => isset($product_option['value']) ? $product_option['value'] : '',
    979 				'required'             => $product_option['required']
    980 			);
    981 		}
    982 
    983 		$data['option_values'] = array();
    984 
    985 		foreach ($data['product_options'] as $product_option) {
    986 			if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
    987 				if (!isset($data['option_values'][$product_option['option_id']])) {
    988 					$data['option_values'][$product_option['option_id']] = $this->model_catalog_option->getOptionValues($product_option['option_id']);
    989 				}
    990 			}
    991 		}
    992 
    993 		$this->load->model('customer/customer_group');
    994 
    995 		$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
    996 
    997 		if (isset($this->request->post['product_discount'])) {
    998 			$product_discounts = $this->request->post['product_discount'];
    999 		} elseif (isset($this->request->get['product_id'])) {
   1000 			$product_discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
   1001 		} else {
   1002 			$product_discounts = array();
   1003 		}
   1004 
   1005 		$data['product_discounts'] = array();
   1006 
   1007 		foreach ($product_discounts as $product_discount) {
   1008 			$data['product_discounts'][] = array(
   1009 				'customer_group_id' => $product_discount['customer_group_id'],
   1010 				'quantity'          => $product_discount['quantity'],
   1011 				'priority'          => $product_discount['priority'],
   1012 				'price'             => $product_discount['price'],
   1013 				'date_start'        => ($product_discount['date_start'] != '0000-00-00') ? $product_discount['date_start'] : '',
   1014 				'date_end'          => ($product_discount['date_end'] != '0000-00-00') ? $product_discount['date_end'] : ''
   1015 			);
   1016 		}
   1017 
   1018 		if (isset($this->request->post['product_special'])) {
   1019 			$product_specials = $this->request->post['product_special'];
   1020 		} elseif (isset($this->request->get['product_id'])) {
   1021 			$product_specials = $this->model_catalog_product->getProductSpecials($this->request->get['product_id']);
   1022 		} else {
   1023 			$product_specials = array();
   1024 		}
   1025 
   1026 		$data['product_specials'] = array();
   1027 
   1028 		foreach ($product_specials as $product_special) {
   1029 			$data['product_specials'][] = array(
   1030 				'customer_group_id' => $product_special['customer_group_id'],
   1031 				'priority'          => $product_special['priority'],
   1032 				'price'             => $product_special['price'],
   1033 				'date_start'        => ($product_special['date_start'] != '0000-00-00') ? $product_special['date_start'] : '',
   1034 				'date_end'          => ($product_special['date_end'] != '0000-00-00') ? $product_special['date_end'] :  ''
   1035 			);
   1036 		}
   1037 		
   1038 		// Image
   1039 		if (isset($this->request->post['image'])) {
   1040 			$data['image'] = $this->request->post['image'];
   1041 		} elseif (!empty($product_info)) {
   1042 			$data['image'] = $product_info['image'];
   1043 		} else {
   1044 			$data['image'] = '';
   1045 		}
   1046 
   1047 		$this->load->model('tool/image');
   1048 
   1049 		if (isset($this->request->post['image']) && is_file(DIR_IMAGE . $this->request->post['image'])) {
   1050 			$data['thumb'] = $this->model_tool_image->resize($this->request->post['image'], 100, 100);
   1051 		} elseif (!empty($product_info) && is_file(DIR_IMAGE . $product_info['image'])) {
   1052 			$data['thumb'] = $this->model_tool_image->resize($product_info['image'], 100, 100);
   1053 		} else {
   1054 			$data['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
   1055 		}
   1056 
   1057 		$data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
   1058 
   1059 		// Images
   1060 		if (isset($this->request->post['product_image'])) {
   1061 			$product_images = $this->request->post['product_image'];
   1062 		} elseif (isset($this->request->get['product_id'])) {
   1063 			$product_images = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
   1064 		} else {
   1065 			$product_images = array();
   1066 		}
   1067 
   1068 		$data['product_images'] = array();
   1069 
   1070 		foreach ($product_images as $product_image) {
   1071 			if (is_file(DIR_IMAGE . $product_image['image'])) {
   1072 				$image = $product_image['image'];
   1073 				$thumb = $product_image['image'];
   1074 			} else {
   1075 				$image = '';
   1076 				$thumb = 'no_image.png';
   1077 			}
   1078 
   1079 			$data['product_images'][] = array(
   1080 				'image'      => $image,
   1081 				'thumb'      => $this->model_tool_image->resize($thumb, 100, 100),
   1082 				'sort_order' => $product_image['sort_order']
   1083 			);
   1084 		}
   1085 
   1086 		// Downloads
   1087 		$this->load->model('catalog/download');
   1088 
   1089 		if (isset($this->request->post['product_download'])) {
   1090 			$product_downloads = $this->request->post['product_download'];
   1091 		} elseif (isset($this->request->get['product_id'])) {
   1092 			$product_downloads = $this->model_catalog_product->getProductDownloads($this->request->get['product_id']);
   1093 		} else {
   1094 			$product_downloads = array();
   1095 		}
   1096 
   1097 		$data['product_downloads'] = array();
   1098 
   1099 		foreach ($product_downloads as $download_id) {
   1100 			$download_info = $this->model_catalog_download->getDownload($download_id);
   1101 
   1102 			if ($download_info) {
   1103 				$data['product_downloads'][] = array(
   1104 					'download_id' => $download_info['download_id'],
   1105 					'name'        => $download_info['name']
   1106 				);
   1107 			}
   1108 		}
   1109 
   1110 		if (isset($this->request->post['product_related'])) {
   1111 			$products = $this->request->post['product_related'];
   1112 		} elseif (isset($this->request->get['product_id'])) {
   1113 			$products = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
   1114 		} else {
   1115 			$products = array();
   1116 		}
   1117 
   1118 		$data['product_relateds'] = array();
   1119 
   1120 		foreach ($products as $product_id) {
   1121 			$related_info = $this->model_catalog_product->getProduct($product_id);
   1122 
   1123 			if ($related_info) {
   1124 				$data['product_relateds'][] = array(
   1125 					'product_id' => $related_info['product_id'],
   1126 					'name'       => $related_info['name']
   1127 				);
   1128 			}
   1129 		}
   1130 
   1131 		if (isset($this->request->post['points'])) {
   1132 			$data['points'] = $this->request->post['points'];
   1133 		} elseif (!empty($product_info)) {
   1134 			$data['points'] = $product_info['points'];
   1135 		} else {
   1136 			$data['points'] = '';
   1137 		}
   1138 
   1139 		if (isset($this->request->post['product_reward'])) {
   1140 			$data['product_reward'] = $this->request->post['product_reward'];
   1141 		} elseif (isset($this->request->get['product_id'])) {
   1142 			$data['product_reward'] = $this->model_catalog_product->getProductRewards($this->request->get['product_id']);
   1143 		} else {
   1144 			$data['product_reward'] = array();
   1145 		}
   1146 
   1147 		if (isset($this->request->post['product_seo_url'])) {
   1148 			$data['product_seo_url'] = $this->request->post['product_seo_url'];
   1149 		} elseif (isset($this->request->get['product_id'])) {
   1150 			$data['product_seo_url'] = $this->model_catalog_product->getProductSeoUrls($this->request->get['product_id']);
   1151 		} else {
   1152 			$data['product_seo_url'] = array();
   1153 		}
   1154 
   1155 		if (isset($this->request->post['product_layout'])) {
   1156 			$data['product_layout'] = $this->request->post['product_layout'];
   1157 		} elseif (isset($this->request->get['product_id'])) {
   1158 			$data['product_layout'] = $this->model_catalog_product->getProductLayouts($this->request->get['product_id']);
   1159 		} else {
   1160 			$data['product_layout'] = array();
   1161 		}
   1162 
   1163 		$this->load->model('design/layout');
   1164 
   1165 		$data['layouts'] = $this->model_design_layout->getLayouts();
   1166 		
   1167 		$data['header'] = $this->load->controller('common/header');
   1168 		$data['column_left'] = $this->load->controller('common/column_left');
   1169 		$data['footer'] = $this->load->controller('common/footer');
   1170 
   1171 		$this->response->setOutput($this->load->view('catalog/product_form', $data));
   1172 	}
   1173 
   1174 	protected function validateForm() {
   1175 		if (!$this->user->hasPermission('modify', 'catalog/product')) {
   1176 			$this->error['warning'] = $this->language->get('error_permission');
   1177 		}
   1178 
   1179 		foreach ($this->request->post['product_description'] as $language_id => $value) {
   1180 			if ((utf8_strlen($value['name']) < 1) || (utf8_strlen($value['name']) > 255)) {
   1181 				$this->error['name'][$language_id] = $this->language->get('error_name');
   1182 			}
   1183 
   1184 			if ((utf8_strlen($value['meta_title']) < 1) || (utf8_strlen($value['meta_title']) > 255)) {
   1185 				$this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
   1186 			}
   1187 		}
   1188 
   1189 		if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
   1190 			$this->error['model'] = $this->language->get('error_model');
   1191 		}
   1192 
   1193 		if ($this->request->post['product_seo_url']) {
   1194 			$this->load->model('design/seo_url');
   1195 			
   1196 			foreach ($this->request->post['product_seo_url'] as $store_id => $language) {
   1197 				foreach ($language as $language_id => $keyword) {
   1198 					if (!empty($keyword)) {
   1199 						if (count(array_keys($language, $keyword)) > 1) {
   1200 							$this->error['keyword'][$store_id][$language_id] = $this->language->get('error_unique');
   1201 						}						
   1202 						
   1203 						$seo_urls = $this->model_design_seo_url->getSeoUrlsByKeyword($keyword);
   1204 						
   1205 						foreach ($seo_urls as $seo_url) {
   1206 							if (($seo_url['store_id'] == $store_id) && (!isset($this->request->get['product_id']) || (($seo_url['query'] != 'product_id=' . $this->request->get['product_id'])))) {
   1207 								$this->error['keyword'][$store_id][$language_id] = $this->language->get('error_keyword');
   1208 								
   1209 								break;
   1210 							}
   1211 						}
   1212 					}
   1213 				}
   1214 			}
   1215 		}
   1216 
   1217 		if ($this->error && !isset($this->error['warning'])) {
   1218 			$this->error['warning'] = $this->language->get('error_warning');
   1219 		}
   1220 
   1221 		return !$this->error;
   1222 	}
   1223 
   1224 	protected function validateDelete() {
   1225 		if (!$this->user->hasPermission('modify', 'catalog/product')) {
   1226 			$this->error['warning'] = $this->language->get('error_permission');
   1227 		}
   1228 
   1229 		return !$this->error;
   1230 	}
   1231 
   1232 	protected function validateCopy() {
   1233 		if (!$this->user->hasPermission('modify', 'catalog/product')) {
   1234 			$this->error['warning'] = $this->language->get('error_permission');
   1235 		}
   1236 
   1237 		return !$this->error;
   1238 	}
   1239 
   1240 	public function autocomplete() {
   1241 		$json = array();
   1242 
   1243 		if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_model'])) {
   1244 			$this->load->model('catalog/product');
   1245 			$this->load->model('catalog/option');
   1246 
   1247 			if (isset($this->request->get['filter_name'])) {
   1248 				$filter_name = $this->request->get['filter_name'];
   1249 			} else {
   1250 				$filter_name = '';
   1251 			}
   1252 
   1253 			if (isset($this->request->get['filter_model'])) {
   1254 				$filter_model = $this->request->get['filter_model'];
   1255 			} else {
   1256 				$filter_model = '';
   1257 			}
   1258 
   1259 			if (isset($this->request->get['limit'])) {
   1260 				$limit = $this->request->get['limit'];
   1261 			} else {
   1262 				$limit = 5;
   1263 			}
   1264 
   1265 			$filter_data = array(
   1266 				'filter_name'  => $filter_name,
   1267 				'filter_model' => $filter_model,
   1268 				'start'        => 0,
   1269 				'limit'        => $limit
   1270 			);
   1271 
   1272 			$results = $this->model_catalog_product->getProducts($filter_data);
   1273 
   1274 			foreach ($results as $result) {
   1275 				$option_data = array();
   1276 
   1277 				$product_options = $this->model_catalog_product->getProductOptions($result['product_id']);
   1278 
   1279 				foreach ($product_options as $product_option) {
   1280 					$option_info = $this->model_catalog_option->getOption($product_option['option_id']);
   1281 
   1282 					if ($option_info) {
   1283 						$product_option_value_data = array();
   1284 
   1285 						foreach ($product_option['product_option_value'] as $product_option_value) {
   1286 							$option_value_info = $this->model_catalog_option->getOptionValue($product_option_value['option_value_id']);
   1287 
   1288 							if ($option_value_info) {
   1289 								$product_option_value_data[] = array(
   1290 									'product_option_value_id' => $product_option_value['product_option_value_id'],
   1291 									'option_value_id'         => $product_option_value['option_value_id'],
   1292 									'name'                    => $option_value_info['name'],
   1293 									'price'                   => (float)$product_option_value['price'] ? $this->currency->format($product_option_value['price'], $this->config->get('config_currency')) : false,
   1294 									'price_prefix'            => $product_option_value['price_prefix']
   1295 								);
   1296 							}
   1297 						}
   1298 
   1299 						$option_data[] = array(
   1300 							'product_option_id'    => $product_option['product_option_id'],
   1301 							'product_option_value' => $product_option_value_data,
   1302 							'option_id'            => $product_option['option_id'],
   1303 							'name'                 => $option_info['name'],
   1304 							'type'                 => $option_info['type'],
   1305 							'value'                => $product_option['value'],
   1306 							'required'             => $product_option['required']
   1307 						);
   1308 					}
   1309 				}
   1310 
   1311 				$json[] = array(
   1312 					'product_id' => $result['product_id'],
   1313 					'name'       => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')),
   1314 					'model'      => $result['model'],
   1315 					'option'     => $option_data,
   1316 					'price'      => $result['price']
   1317 				);
   1318 			}
   1319 		}
   1320 
   1321 		$this->response->addHeader('Content-Type: application/json');
   1322 		$this->response->setOutput(json_encode($json));
   1323 	}
   1324 }