first commit
This commit is contained in:
@@ -0,0 +1,498 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ControllerProductCategory extends Controller {
|
||||
public function index() {
|
||||
$this->load->language('product/category');
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$this->document->addStyle('store/view/theme/dominik/assets/css/swiper-bundle.min.css');
|
||||
$this->document->addScript('store/view/theme/dominik/assets/js/swiper-bundle.js');
|
||||
$this->load->model('tool/image');
|
||||
|
||||
|
||||
$data['text_empty'] = $this->language->get('text_empty');
|
||||
|
||||
if ($this->config->get('config_noindex_disallow_params')) {
|
||||
$params = explode ("\r\n", $this->config->get('config_noindex_disallow_params'));
|
||||
if(!empty($params)) {
|
||||
$disallow_params = $params;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$filter = $this->request->get['filter'];
|
||||
if (!in_array('filter', $disallow_params, true) && $this->config->get('config_noindex_status')){
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$filter = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
if (!in_array('sort', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$sort = 'p.sort_order';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
if (!in_array('order', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
if (!in_array('page', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$limit = (int)$this->request->get['limit'];
|
||||
if (!in_array('limit', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
if (isset($this->request->get['path'])) {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$path = '';
|
||||
|
||||
$parts = explode('_', (string)$this->request->get['path']);
|
||||
|
||||
$category_id = (int)array_pop($parts);
|
||||
|
||||
foreach ($parts as $path_id) {
|
||||
if (!$path) {
|
||||
$path = (int)$path_id;
|
||||
} else {
|
||||
$path .= '_' . (int)$path_id;
|
||||
}
|
||||
|
||||
$category_info = $this->model_catalog_category->getCategory($path_id);
|
||||
|
||||
if ($category_info) {
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $category_info['name'],
|
||||
'href' => $this->url->link('product/category', 'path=' . $path . $url)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$category_id = 0;
|
||||
}
|
||||
|
||||
$category_info = $this->model_catalog_category->getCategory($category_id);
|
||||
|
||||
if ($category_info) {
|
||||
|
||||
if ($category_info['meta_title']) {
|
||||
$this->document->setTitle($category_info['meta_title']);
|
||||
} else {
|
||||
$this->document->setTitle($category_info['name']);
|
||||
}
|
||||
|
||||
if ($category_info['noindex'] <= 0 && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
|
||||
if ($category_info['meta_h1']) {
|
||||
$data['heading_title'] = $category_info['meta_h1'];
|
||||
} else {
|
||||
$data['heading_title'] = $category_info['name'];
|
||||
}
|
||||
|
||||
$this->document->setDescription($category_info['meta_description']);
|
||||
$this->document->setKeywords($category_info['meta_keyword']);
|
||||
|
||||
$data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
|
||||
|
||||
// Set the last category breadcrumb
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $category_info['name'],
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'])
|
||||
);
|
||||
|
||||
if ($category_info['image']) {
|
||||
$data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_height'));
|
||||
} else {
|
||||
$data['thumb'] = '';
|
||||
}
|
||||
|
||||
$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
|
||||
$data['compare'] = $this->url->link('product/compare');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['categories'] = array();
|
||||
|
||||
$results = $this->model_catalog_category->getCategories($category_id);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$filter_data = array(
|
||||
'filter_category_id' => $result['category_id'],
|
||||
'filter_sub_category' => true
|
||||
);
|
||||
|
||||
$data['categories'][] = array(
|
||||
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
|
||||
'thumb' => $this->model_tool_image->resize($result['image'] ? $result['image'] : 'placeholder.png', 180, 180),
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
$filter_data = array(
|
||||
'filter_category_id' => $category_id,
|
||||
'filter_filter' => $filter,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
);
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
|
||||
|
||||
$results = $this->model_catalog_product->getProducts($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($result['special']) && (float)$result['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$result['special'];
|
||||
} else {
|
||||
$special = false;
|
||||
$tax_price = (float)$result['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$tax = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$tax = false;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$rating = (int)$result['rating'];
|
||||
} else {
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$results = $this->model_catalog_product->getProductImages($result['product_id']);
|
||||
if($results){
|
||||
$additional_image = $this->model_tool_image->resize($results[0]['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$additional_image = false;
|
||||
}
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'additional_thumb' => $additional_image,
|
||||
'price_n' => $result['price'],
|
||||
'price_2' => $this->currency->format($this->tax->calculate($result['price_2'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'price_2_n' => $result['price_2'],
|
||||
'price_3' => $this->currency->format($this->tax->calculate($result['price_3'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'price_3_n' => $result['price_3'],
|
||||
'min_price' => $this->currency->format($this->tax->calculate(min([$result['price'],$result['price_2']]), $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $result['rating'],
|
||||
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['sorts'] = array();
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_default'),
|
||||
'value' => 'p.sort_order-ASC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_asc'),
|
||||
'value' => 'pd.name-ASC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_desc'),
|
||||
'value' => 'pd.name-DESC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_asc'),
|
||||
'value' => 'p.price-ASC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_desc'),
|
||||
'value' => 'p.price-DESC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=DESC' . $url)
|
||||
);
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_desc'),
|
||||
'value' => 'rating-DESC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_asc'),
|
||||
'value' => 'rating-ASC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=ASC' . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_asc'),
|
||||
'value' => 'p.model-ASC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_desc'),
|
||||
'value' => 'p.model-DESC',
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['limits'] = array();
|
||||
|
||||
$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));
|
||||
|
||||
sort($limits);
|
||||
|
||||
foreach($limits as $value) {
|
||||
$data['limits'][] = array(
|
||||
'text' => $value,
|
||||
'value' => $value,
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&limit=' . $value)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $product_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $limit;
|
||||
$pagination->url = $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page={page}');
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));
|
||||
|
||||
if (!$this->config->get('config_canonical_method')) {
|
||||
// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
|
||||
if ($page == 1) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
|
||||
} elseif ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'prev');
|
||||
} else {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . ($page + 1)), 'next');
|
||||
}
|
||||
} else {
|
||||
|
||||
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
|
||||
$server = $this->config->get('config_ssl');
|
||||
} else {
|
||||
$server = $this->config->get('config_url');
|
||||
};
|
||||
|
||||
$request_url = rtrim($server, '/') . $this->request->server['REQUEST_URI'];
|
||||
$canonical_url = $this->url->link('product/category', 'path=' . $category_info['category_id']);
|
||||
|
||||
if (($request_url != $canonical_url) || $this->config->get('config_canonical_self')) {
|
||||
$this->document->addLink($canonical_url, 'canonical');
|
||||
}
|
||||
|
||||
if ($this->config->get('config_add_prevnext')) {
|
||||
|
||||
if ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'prev');
|
||||
} elseif ($page > 2) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . ($page + 1)), 'next');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
$data['limit'] = $limit;
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/category', $data));
|
||||
} else {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['path'])) {
|
||||
$url .= '&path=' . $this->request->get['path'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_error'),
|
||||
'href' => $this->url->link('product/category', $url)
|
||||
);
|
||||
|
||||
$this->document->setTitle($this->language->get('text_error'));
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('error/not_found', $data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
class ControllerProductCompare extends Controller {
|
||||
public function index() {
|
||||
$this->load->language('product/compare');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if (!isset($this->session->data['compare'])) {
|
||||
$this->session->data['compare'] = array();
|
||||
}
|
||||
|
||||
if (isset($this->request->get['remove'])) {
|
||||
$key = array_search($this->request->get['remove'], $this->session->data['compare']);
|
||||
|
||||
if ($key !== false) {
|
||||
unset($this->session->data['compare'][$key]);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_remove');
|
||||
}
|
||||
|
||||
$this->response->redirect($this->url->link('product/compare'));
|
||||
}
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('product/compare')
|
||||
);
|
||||
|
||||
if (isset($this->session->data['success'])) {
|
||||
$data['success'] = $this->session->data['success'];
|
||||
|
||||
unset($this->session->data['success']);
|
||||
} else {
|
||||
$data['success'] = '';
|
||||
}
|
||||
|
||||
$data['review_status'] = $this->config->get('config_review_status');
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
$data['attribute_groups'] = array();
|
||||
|
||||
foreach ($this->session->data['compare'] as $key => $product_id) {
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
if ($product_info) {
|
||||
if ($product_info['image']) {
|
||||
$image = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_compare_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_compare_height'));
|
||||
} else {
|
||||
$image = false;
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($product_info['special']) && (float)$product_info['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$special = false;
|
||||
}
|
||||
|
||||
if ($product_info['quantity'] <= 0) {
|
||||
$availability = $product_info['stock_status'];
|
||||
} elseif ($this->config->get('config_stock_display')) {
|
||||
$availability = $product_info['quantity'];
|
||||
} else {
|
||||
$availability = $this->language->get('text_instock');
|
||||
}
|
||||
|
||||
$attribute_data = array();
|
||||
|
||||
$attribute_groups = $this->model_catalog_product->getProductAttributes($product_id);
|
||||
|
||||
foreach ($attribute_groups as $attribute_group) {
|
||||
foreach ($attribute_group['attribute'] as $attribute) {
|
||||
$attribute_data[$attribute['attribute_id']] = $attribute['text'];
|
||||
}
|
||||
}
|
||||
|
||||
$data['products'][$product_id] = array(
|
||||
'product_id' => $product_info['product_id'],
|
||||
'name' => $product_info['name'],
|
||||
'thumb' => $image,
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 200) . '..',
|
||||
'model' => $product_info['model'],
|
||||
'manufacturer' => $product_info['manufacturer'],
|
||||
'availability' => $availability,
|
||||
'minimum' => $product_info['minimum'] > 0 ? $product_info['minimum'] : 1,
|
||||
'rating' => (int)$product_info['rating'],
|
||||
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
|
||||
'weight' => $this->weight->format($product_info['weight'], $product_info['weight_class_id']),
|
||||
'length' => $this->length->format($product_info['length'], $product_info['length_class_id']),
|
||||
'width' => $this->length->format($product_info['width'], $product_info['length_class_id']),
|
||||
'height' => $this->length->format($product_info['height'], $product_info['length_class_id']),
|
||||
'attribute' => $attribute_data,
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $product_id),
|
||||
'remove' => $this->url->link('product/compare', 'remove=' . $product_id)
|
||||
);
|
||||
|
||||
foreach ($attribute_groups as $attribute_group) {
|
||||
$data['attribute_groups'][$attribute_group['attribute_group_id']]['name'] = $attribute_group['name'];
|
||||
|
||||
foreach ($attribute_group['attribute'] as $attribute) {
|
||||
$data['attribute_groups'][$attribute_group['attribute_group_id']]['attribute'][$attribute['attribute_id']]['name'] = $attribute['name'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unset($this->session->data['compare'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/compare', $data));
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$this->load->language('product/compare');
|
||||
|
||||
$json = array();
|
||||
|
||||
if (!isset($this->session->data['compare'])) {
|
||||
$this->session->data['compare'] = array();
|
||||
}
|
||||
|
||||
if (isset($this->request->post['product_id'])) {
|
||||
$product_id = $this->request->post['product_id'];
|
||||
} else {
|
||||
$product_id = 0;
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
if ($product_info) {
|
||||
if (!in_array($this->request->post['product_id'], $this->session->data['compare'])) {
|
||||
if (count($this->session->data['compare']) >= 4) {
|
||||
array_shift($this->session->data['compare']);
|
||||
}
|
||||
|
||||
$this->session->data['compare'][] = $this->request->post['product_id'];
|
||||
}
|
||||
|
||||
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('product/compare'));
|
||||
|
||||
$json['total'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
class ControllerProductManufacturer extends Controller {
|
||||
public function index() {
|
||||
$this->load->language('product/manufacturer');
|
||||
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_brand'),
|
||||
'href' => $this->url->link('product/manufacturer')
|
||||
);
|
||||
|
||||
$data['categories'] = array();
|
||||
|
||||
$results = $this->model_catalog_manufacturer->getManufacturers();
|
||||
|
||||
foreach ($results as $result) {
|
||||
if (is_numeric(utf8_substr($result['name'], 0, 1))) {
|
||||
$key = '0 - 9';
|
||||
} else {
|
||||
$key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);
|
||||
}
|
||||
|
||||
if (!isset($data['categories'][$key])) {
|
||||
$data['categories'][$key]['name'] = $key;
|
||||
}
|
||||
|
||||
$data['categories'][$key]['manufacturer'][] = array(
|
||||
'name' => $result['name'],
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
|
||||
);
|
||||
}
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/manufacturer_list', $data));
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$this->load->language('product/manufacturer');
|
||||
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if (isset($this->request->get['manufacturer_id'])) {
|
||||
$manufacturer_id = (int)$this->request->get['manufacturer_id'];
|
||||
} else {
|
||||
$manufacturer_id = 0;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_noindex_disallow_params')) {
|
||||
$params = explode ("\r\n", $this->config->get('config_noindex_disallow_params'));
|
||||
if(!empty($params)) {
|
||||
$disallow_params = $params;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
if (!in_array('sort', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$sort = 'p.sort_order';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
if (!in_array('order', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
if (!in_array('page', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$limit = (int)$this->request->get['limit'];
|
||||
if (!in_array('limit', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$limit = (int)$this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_brand'),
|
||||
'href' => $this->url->link('product/manufacturer')
|
||||
);
|
||||
|
||||
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id);
|
||||
|
||||
if ($manufacturer_info) {
|
||||
|
||||
if ($manufacturer_info['meta_title']) {
|
||||
$this->document->setTitle($manufacturer_info['meta_title']);
|
||||
} else {
|
||||
$this->document->setTitle($manufacturer_info['name']);
|
||||
}
|
||||
|
||||
if ($manufacturer_info['noindex'] <= 0 && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
|
||||
if ($manufacturer_info['meta_h1']) {
|
||||
$data['heading_title'] = $manufacturer_info['meta_h1'];
|
||||
} else {
|
||||
$data['heading_title'] = $manufacturer_info['name'];
|
||||
}
|
||||
|
||||
$this->document->setDescription($manufacturer_info['meta_description']);
|
||||
$this->document->setKeywords($manufacturer_info['meta_keyword']);
|
||||
$data['description'] = html_entity_decode($manufacturer_info['description'], ENT_QUOTES, 'UTF-8');
|
||||
|
||||
|
||||
if ($manufacturer_info['image']) {
|
||||
$data['thumb'] = $this->model_tool_image->resize($manufacturer_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_manufacturer_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_manufacturer_height'));
|
||||
} else {
|
||||
$data['thumb'] = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $manufacturer_info['name'],
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url)
|
||||
);
|
||||
|
||||
$data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
|
||||
|
||||
$data['compare'] = $this->url->link('product/compare');
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
$filter_data = array(
|
||||
'filter_manufacturer_id' => $manufacturer_id,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
);
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
|
||||
|
||||
$results = $this->model_catalog_product->getProducts($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($result['special']) && (float)$result['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$result['special'];
|
||||
} else {
|
||||
$special = false;
|
||||
$tax_price = (float)$result['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$tax = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$tax = false;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$rating = (int)$result['rating'];
|
||||
} else {
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $result['rating'],
|
||||
'href' => $this->url->link('product/product', 'manufacturer_id=' . $result['manufacturer_id'] . '&product_id=' . $result['product_id'] . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['sorts'] = array();
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_default'),
|
||||
'value' => 'p.sort_order-ASC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.sort_order&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_asc'),
|
||||
'value' => 'pd.name-ASC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=pd.name&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_desc'),
|
||||
'value' => 'pd.name-DESC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=pd.name&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_asc'),
|
||||
'value' => 'p.price-ASC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.price&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_desc'),
|
||||
'value' => 'p.price-DESC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.price&order=DESC' . $url)
|
||||
);
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_desc'),
|
||||
'value' => 'rating-DESC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=rating&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_asc'),
|
||||
'value' => 'rating-ASC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=rating&order=ASC' . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_asc'),
|
||||
'value' => 'p.model-ASC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.model&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_desc'),
|
||||
'value' => 'p.model-DESC',
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&sort=p.model&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['limits'] = array();
|
||||
|
||||
$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));
|
||||
|
||||
sort($limits);
|
||||
|
||||
foreach($limits as $value) {
|
||||
$data['limits'][] = array(
|
||||
'text' => $value,
|
||||
'value' => $value,
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&limit=' . $value)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $product_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $limit;
|
||||
$pagination->url = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&page={page}');
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));
|
||||
|
||||
if (!$this->config->get('config_canonical_method')) {
|
||||
// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
|
||||
if ($page == 1) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id']), 'canonical');
|
||||
} elseif ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id']), 'prev');
|
||||
} else {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page=' . ($page + 1)), 'next');
|
||||
}
|
||||
} else {
|
||||
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
|
||||
$server = $this->config->get('config_ssl');
|
||||
} else {
|
||||
$server = $this->config->get('config_url');
|
||||
};
|
||||
|
||||
$request_url = rtrim($server, '/') . $this->request->server['REQUEST_URI'];
|
||||
$canonical_url = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id']);
|
||||
|
||||
if (($request_url != $canonical_url) || $this->config->get('config_canonical_self')) {
|
||||
$this->document->addLink($canonical_url, 'canonical');
|
||||
}
|
||||
|
||||
if ($this->config->get('config_add_prevnext')) {
|
||||
|
||||
if ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id']), 'prev');
|
||||
} elseif ($page > 2) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . '&page=' . ($page + 1)), 'next');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
$data['limit'] = $limit;
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/manufacturer_info', $data));
|
||||
} else {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['manufacturer_id'])) {
|
||||
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_error'),
|
||||
'href' => $this->url->link('product/manufacturer/info', $url)
|
||||
);
|
||||
|
||||
$this->document->setTitle($this->language->get('text_error'));
|
||||
|
||||
$data['heading_title'] = $this->language->get('text_error');
|
||||
|
||||
$data['text_error'] = $this->language->get('text_error');
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
|
||||
$this->response->setOutput($this->load->view('error/not_found', $data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,703 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ControllerProductProduct extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index() {
|
||||
$this->load->language('product/product');
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
if (isset($this->request->get['path'])) {
|
||||
$path = '';
|
||||
|
||||
$parts = explode('_', (string)$this->request->get['path']);
|
||||
|
||||
$category_id = (int)array_pop($parts);
|
||||
|
||||
foreach ($parts as $path_id) {
|
||||
if (!$path) {
|
||||
$path = $path_id;
|
||||
} else {
|
||||
$path .= '_' . $path_id;
|
||||
}
|
||||
|
||||
$category_info = $this->model_catalog_category->getCategory($path_id);
|
||||
|
||||
if ($category_info) {
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $category_info['name'],
|
||||
'href' => $this->url->link('product/category', 'path=' . $path)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the last category breadcrumb
|
||||
$category_info = $this->model_catalog_category->getCategory($category_id);
|
||||
|
||||
if ($category_info) {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $category_info['name'],
|
||||
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
if (isset($this->request->get['manufacturer_id'])) {
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_brand'),
|
||||
'href' => $this->url->link('product/manufacturer')
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
|
||||
|
||||
if ($manufacturer_info) {
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $manufacturer_info['name'],
|
||||
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . $this->request->get['search'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . $this->request->get['tag'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_search'),
|
||||
'href' => $this->url->link('product/search', $url)
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['product_id'])) {
|
||||
$product_id = (int)$this->request->get['product_id'];
|
||||
} else {
|
||||
$product_id = 0;
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
if ($product_info) {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['path'])) {
|
||||
$url .= '&path=' . $this->request->get['path'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['manufacturer_id'])) {
|
||||
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . $this->request->get['search'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . $this->request->get['tag'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $product_info['name'],
|
||||
'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
|
||||
);
|
||||
|
||||
if ($product_info['meta_title']) {
|
||||
$this->document->setTitle($product_info['meta_title']);
|
||||
} else {
|
||||
$this->document->setTitle($product_info['name']);
|
||||
}
|
||||
|
||||
if ($product_info['noindex'] <= 0 && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
|
||||
if ($product_info['meta_h1']) {
|
||||
$data['heading_title'] = $product_info['meta_h1'];
|
||||
} else {
|
||||
$data['heading_title'] = $product_info['name'];
|
||||
}
|
||||
|
||||
$this->document->setDescription($product_info['meta_description']);
|
||||
$this->document->setKeywords($product_info['meta_keyword']);
|
||||
$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
|
||||
$this->document->addScript('store/view/javascript/jquery/magnific/jquery.magnific-popup.min.js');
|
||||
$this->document->addStyle('store/view/javascript/jquery/magnific/magnific-popup.css');
|
||||
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment.min.js');
|
||||
$this->document->addScript('store/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
|
||||
$this->document->addScript('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
|
||||
$this->document->addStyle('store/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
|
||||
|
||||
$data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
|
||||
$data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true));
|
||||
|
||||
$this->load->model('catalog/review');
|
||||
|
||||
$data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
|
||||
|
||||
$data['product_id'] = (int)$this->request->get['product_id'];
|
||||
$data['manufacturer'] = $product_info['manufacturer'];
|
||||
$data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
|
||||
$data['model'] = $product_info['model'];
|
||||
$data['reward'] = $product_info['reward'];
|
||||
$data['points'] = $product_info['points'];
|
||||
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
|
||||
|
||||
if ($product_info['quantity'] <= 0) {
|
||||
$data['stock'] = $product_info['stock_status'];
|
||||
} elseif ($this->config->get('config_stock_display')) {
|
||||
$data['stock'] = $product_info['quantity'];
|
||||
} else {
|
||||
$data['stock'] = $this->language->get('text_instock');
|
||||
}
|
||||
|
||||
$this->document->addStyle('store/view/theme/dominik/assets/css/swiper-bundle.min.css');
|
||||
$this->document->addScript('store/view/theme/dominik/assets/js/swiper-bundle.js');
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if ($product_info['image']) {
|
||||
$data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height'));
|
||||
} else {
|
||||
$data['popup'] = '';
|
||||
}
|
||||
|
||||
if ($product_info['image']) {
|
||||
$data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));
|
||||
} else {
|
||||
$data['thumb'] = '';
|
||||
}
|
||||
|
||||
$data['images'] = array();
|
||||
if($product_info['image']){
|
||||
|
||||
$data['images'][] = array(
|
||||
'popup' => $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
|
||||
'thumb' => $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
|
||||
);
|
||||
}
|
||||
|
||||
$this->document->addScript('store/view/theme/dominik/assets/js/zoomove.min.js');
|
||||
$this->document->addStyle('store/view/theme/dominik/assets/css/zoomove.min.css');
|
||||
|
||||
$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['images'][] = array(
|
||||
'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
|
||||
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$data['price'] = false;
|
||||
}
|
||||
|
||||
foreach(['price_2','price_3'] as $pp){
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$data[$pp] = $this->currency->format($this->tax->calculate($product_info[$pp], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$data[$pp] = false;
|
||||
}
|
||||
$data[$pp . '_n'] = $product_info[$pp];
|
||||
}
|
||||
$data['price_n'] = $product_info['price'];
|
||||
if (!is_null($product_info['special']) && (float)$product_info['special'] >= 0) {
|
||||
$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$product_info['special'];
|
||||
} else {
|
||||
$data['special'] = false;
|
||||
$tax_price = (float)$product_info['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$data['tax'] = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$data['tax'] = false;
|
||||
}
|
||||
|
||||
$discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
|
||||
|
||||
$data['discounts'] = array();
|
||||
|
||||
foreach ($discounts as $discount) {
|
||||
$data['discounts'][] = array(
|
||||
'quantity' => $discount['quantity'],
|
||||
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
|
||||
);
|
||||
}
|
||||
|
||||
$data['options'] = array();
|
||||
|
||||
foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
|
||||
$product_option_value_data = array();
|
||||
|
||||
foreach ($option['product_option_value'] as $option_value) {
|
||||
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
|
||||
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
|
||||
$price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
$product_option_value_data[] = array(
|
||||
'product_option_value_id' => $option_value['product_option_value_id'],
|
||||
'option_value_id' => $option_value['option_value_id'],
|
||||
'name' => $option_value['name'],
|
||||
'image' => $this->model_tool_image->resize($option_value['image'], 50, 50),
|
||||
'price' => $price,
|
||||
'price_prefix' => $option_value['price_prefix']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data['options'][] = array(
|
||||
'product_option_id' => $option['product_option_id'],
|
||||
'product_option_value' => $product_option_value_data,
|
||||
'option_id' => $option['option_id'],
|
||||
'name' => $option['name'],
|
||||
'type' => $option['type'],
|
||||
'value' => $option['value'],
|
||||
'required' => $option['required']
|
||||
);
|
||||
}
|
||||
|
||||
if ($product_info['minimum']) {
|
||||
$data['minimum'] = $product_info['minimum'];
|
||||
} else {
|
||||
$data['minimum'] = 1;
|
||||
}
|
||||
|
||||
$data['review_status'] = $this->config->get('config_review_status');
|
||||
|
||||
if ($this->config->get('config_review_guest') || $this->customer->isLogged()) {
|
||||
$data['review_guest'] = true;
|
||||
} else {
|
||||
$data['review_guest'] = false;
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged()) {
|
||||
$data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName();
|
||||
} else {
|
||||
$data['customer_name'] = '';
|
||||
}
|
||||
|
||||
$data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']);
|
||||
$data['rating'] = (int)$product_info['rating'];
|
||||
|
||||
// Captcha
|
||||
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
|
||||
$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
|
||||
} else {
|
||||
$data['captcha'] = '';
|
||||
}
|
||||
|
||||
$data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']);
|
||||
|
||||
$data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($result['special']) && (float)$result['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$result['special'];
|
||||
} else {
|
||||
$special = false;
|
||||
$tax_price = (float)$result['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$tax = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$tax = false;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$rating = (int)$result['rating'];
|
||||
} else {
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $rating,
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
|
||||
);
|
||||
}
|
||||
|
||||
$data['tags'] = array();
|
||||
|
||||
if ($product_info['tag']) {
|
||||
$tags = explode(',', $product_info['tag']);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$data['tags'][] = array(
|
||||
'tag' => trim($tag),
|
||||
'href' => $this->url->link('product/search', 'tag=' . trim($tag))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']);
|
||||
|
||||
$this->model_catalog_product->updateViewed($this->request->get['product_id']);
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/product', $data));
|
||||
} else {
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['path'])) {
|
||||
$url .= '&path=' . $this->request->get['path'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter'])) {
|
||||
$url .= '&filter=' . $this->request->get['filter'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['manufacturer_id'])) {
|
||||
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . $this->request->get['search'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . $this->request->get['tag'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_error'),
|
||||
'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id)
|
||||
);
|
||||
|
||||
$this->document->setTitle($this->language->get('text_error'));
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('error/not_found', $data));
|
||||
}
|
||||
}
|
||||
|
||||
public function review() {
|
||||
$this->load->language('product/product');
|
||||
|
||||
$this->load->model('catalog/review');
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['reviews'] = array();
|
||||
|
||||
$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
|
||||
|
||||
$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['reviews'][] = array(
|
||||
'author' => $result['author'],
|
||||
'text' => nl2br($result['text']),
|
||||
'rating' => (int)$result['rating'],
|
||||
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
|
||||
);
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $review_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = 5;
|
||||
$pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5));
|
||||
|
||||
$this->response->setOutput($this->load->view('product/review', $data));
|
||||
}
|
||||
|
||||
public function write() {
|
||||
$this->load->language('product/product');
|
||||
|
||||
$json = array();
|
||||
|
||||
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
|
||||
$json['error'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
|
||||
$json['error'] = $this->language->get('error_text');
|
||||
}
|
||||
|
||||
if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) {
|
||||
$json['error'] = $this->language->get('error_rating');
|
||||
}
|
||||
|
||||
// Captcha
|
||||
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
|
||||
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
|
||||
|
||||
if ($captcha) {
|
||||
$json['error'] = $captcha;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($json['error'])) {
|
||||
$this->load->model('catalog/review');
|
||||
|
||||
$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
public function getRecurringDescription() {
|
||||
$this->load->language('product/product');
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
if (isset($this->request->post['product_id'])) {
|
||||
$product_id = $this->request->post['product_id'];
|
||||
} else {
|
||||
$product_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['recurring_id'])) {
|
||||
$recurring_id = $this->request->post['recurring_id'];
|
||||
} else {
|
||||
$recurring_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->post['quantity'])) {
|
||||
$quantity = $this->request->post['quantity'];
|
||||
} else {
|
||||
$quantity = 1;
|
||||
}
|
||||
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
$recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id);
|
||||
|
||||
$json = array();
|
||||
|
||||
if ($product_info && $recurring_info) {
|
||||
if (!$json) {
|
||||
$frequencies = array(
|
||||
'day' => $this->language->get('text_day'),
|
||||
'week' => $this->language->get('text_week'),
|
||||
'semi_month' => $this->language->get('text_semi_month'),
|
||||
'month' => $this->language->get('text_month'),
|
||||
'year' => $this->language->get('text_year'),
|
||||
);
|
||||
|
||||
if ($recurring_info['trial_status'] == 1) {
|
||||
$price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' ';
|
||||
} else {
|
||||
$trial_text = '';
|
||||
}
|
||||
|
||||
$price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
|
||||
if ($recurring_info['duration']) {
|
||||
$text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
|
||||
} else {
|
||||
$text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
|
||||
}
|
||||
|
||||
$json['success'] = $text;
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ControllerProductSearch extends Controller {
|
||||
public function index() {
|
||||
$this->load->language('product/search');
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$search = $this->request->get['search'];
|
||||
} else {
|
||||
$search = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$tag = $this->request->get['tag'];
|
||||
} elseif (isset($this->request->get['search'])) {
|
||||
$tag = $this->request->get['search'];
|
||||
} else {
|
||||
$tag = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$description = $this->request->get['description'];
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$category_id = $this->request->get['category_id'];
|
||||
} else {
|
||||
$category_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$sub_category = $this->request->get['sub_category'];
|
||||
} else {
|
||||
$sub_category = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'p.sort_order';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$limit = (int)$this->request->get['limit'];
|
||||
} else {
|
||||
$limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
|
||||
}
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$this->document->setTitle($this->language->get('heading_title') . ' - ' . $this->request->get['search']);
|
||||
} elseif (isset($this->request->get['tag'])) {
|
||||
$this->document->setTitle($this->language->get('heading_title') . ' - ' . $this->language->get('heading_tag') . $this->request->get['tag']);
|
||||
} else {
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
}
|
||||
|
||||
$this->document->setRobots('noindex,follow');
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . urlencode(html_entity_decode($this->request->get['tag'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('product/search', $url)
|
||||
);
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['search'];
|
||||
} else {
|
||||
$data['heading_title'] = $this->language->get('heading_title');
|
||||
}
|
||||
|
||||
$this->document->setRobots('noindex,follow');
|
||||
|
||||
$data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
|
||||
|
||||
$data['compare'] = $this->url->link('product/compare');
|
||||
|
||||
// 3 Level Category Search
|
||||
$data['categories'] = array();
|
||||
|
||||
$categories_1 = $this->model_catalog_category->getCategories(0);
|
||||
|
||||
foreach ($categories_1 as $category_1) {
|
||||
$level_2_data = array();
|
||||
|
||||
$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
|
||||
|
||||
foreach ($categories_2 as $category_2) {
|
||||
$level_3_data = array();
|
||||
|
||||
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
|
||||
|
||||
foreach ($categories_3 as $category_3) {
|
||||
$level_3_data[] = array(
|
||||
'category_id' => $category_3['category_id'],
|
||||
'name' => $category_3['name'],
|
||||
);
|
||||
}
|
||||
|
||||
$level_2_data[] = array(
|
||||
'category_id' => $category_2['category_id'],
|
||||
'name' => $category_2['name'],
|
||||
'children' => $level_3_data
|
||||
);
|
||||
}
|
||||
|
||||
$data['categories'][] = array(
|
||||
'category_id' => $category_1['category_id'],
|
||||
'name' => $category_1['name'],
|
||||
'children' => $level_2_data
|
||||
);
|
||||
}
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
|
||||
$filter_data = array(
|
||||
'filter_name' => $search,
|
||||
'filter_tag' => $tag,
|
||||
'filter_description' => $description,
|
||||
'filter_category_id' => $category_id,
|
||||
'filter_sub_category' => $sub_category,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
);
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
|
||||
|
||||
$results = $this->model_catalog_product->getProducts($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($result['special']) && (float)$result['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$result['special'];
|
||||
} else {
|
||||
$special = false;
|
||||
$tax_price = (float)$result['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$tax = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$tax = false;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$rating = (int)$result['rating'];
|
||||
} else {
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $result['rating'],
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . urlencode(html_entity_decode($this->request->get['tag'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['sorts'] = array();
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_default'),
|
||||
'value' => 'p.sort_order-ASC',
|
||||
'href' => $this->url->link('product/search', 'sort=p.sort_order&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_asc'),
|
||||
'value' => 'pd.name-ASC',
|
||||
'href' => $this->url->link('product/search', 'sort=pd.name&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_desc'),
|
||||
'value' => 'pd.name-DESC',
|
||||
'href' => $this->url->link('product/search', 'sort=pd.name&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_asc'),
|
||||
'value' => 'p.price-ASC',
|
||||
'href' => $this->url->link('product/search', 'sort=p.price&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_desc'),
|
||||
'value' => 'p.price-DESC',
|
||||
'href' => $this->url->link('product/search', 'sort=p.price&order=DESC' . $url)
|
||||
);
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_desc'),
|
||||
'value' => 'rating-DESC',
|
||||
'href' => $this->url->link('product/search', 'sort=rating&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_asc'),
|
||||
'value' => 'rating-ASC',
|
||||
'href' => $this->url->link('product/search', 'sort=rating&order=ASC' . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_asc'),
|
||||
'value' => 'p.model-ASC',
|
||||
'href' => $this->url->link('product/search', 'sort=p.model&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_desc'),
|
||||
'value' => 'p.model-DESC',
|
||||
'href' => $this->url->link('product/search', 'sort=p.model&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . urlencode(html_entity_decode($this->request->get['tag'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['limits'] = array();
|
||||
|
||||
$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));
|
||||
|
||||
sort($limits);
|
||||
|
||||
foreach($limits as $value) {
|
||||
$data['limits'][] = array(
|
||||
'text' => $value,
|
||||
'value' => $value,
|
||||
'href' => $this->url->link('product/search', $url . '&limit=' . $value)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['search'])) {
|
||||
$url .= '&search=' . urlencode(html_entity_decode($this->request->get['search'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tag'])) {
|
||||
$url .= '&tag=' . urlencode(html_entity_decode($this->request->get['tag'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['description'])) {
|
||||
$url .= '&description=' . $this->request->get['description'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['category_id'])) {
|
||||
$url .= '&category_id=' . $this->request->get['category_id'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sub_category'])) {
|
||||
$url .= '&sub_category=' . $this->request->get['sub_category'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $product_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $limit;
|
||||
$pagination->url = $this->url->link('product/search', $url . '&page={page}');
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));
|
||||
|
||||
if (isset($this->request->get['search']) && $this->config->get('config_customer_search')) {
|
||||
$this->load->model('account/search');
|
||||
|
||||
if ($this->customer->isLogged()) {
|
||||
$customer_id = $this->customer->getId();
|
||||
} else {
|
||||
$customer_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->server['REMOTE_ADDR'])) {
|
||||
$ip = $this->request->server['REMOTE_ADDR'];
|
||||
} else {
|
||||
$ip = '';
|
||||
}
|
||||
|
||||
$search_data = array(
|
||||
'keyword' => $search,
|
||||
'category_id' => $category_id,
|
||||
'sub_category' => $sub_category,
|
||||
'description' => $description,
|
||||
'products' => $product_total,
|
||||
'customer_id' => $customer_id,
|
||||
'ip' => $ip
|
||||
);
|
||||
|
||||
$this->model_account_search->addSearch($search_data);
|
||||
}
|
||||
}
|
||||
|
||||
$data['search'] = $search;
|
||||
$data['description'] = $description;
|
||||
$data['category_id'] = $category_id;
|
||||
$data['sub_category'] = $sub_category;
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
$data['limit'] = $limit;
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/search', $data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
class ControllerProductSpecial extends Controller {
|
||||
public function index() {
|
||||
$this->load->language('product/special');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if ($this->config->get('config_noindex_disallow_params')) {
|
||||
$params = explode ("\r\n", $this->config->get('config_noindex_disallow_params'));
|
||||
if(!empty($params)) {
|
||||
$disallow_params = $params;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = $this->request->get['sort'];
|
||||
if (!in_array('sort', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$sort = 'p.sort_order';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = $this->request->get['order'];
|
||||
if (!in_array('order', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
if (!in_array('page', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$limit = (int)$this->request->get['limit'];
|
||||
if (!in_array('limit', $disallow_params, true) && $this->config->get('config_noindex_status')) {
|
||||
$this->document->setRobots('noindex,follow');
|
||||
}
|
||||
} else {
|
||||
$limit = $this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit');
|
||||
}
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = array();
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/home')
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('product/special', $url)
|
||||
);
|
||||
|
||||
$data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
|
||||
|
||||
$data['compare'] = $this->url->link('product/compare');
|
||||
|
||||
$data['products'] = array();
|
||||
|
||||
$filter_data = array(
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
);
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProductSpecials();
|
||||
|
||||
$results = $this->model_catalog_product->getProductSpecials($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['image']) {
|
||||
$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
} else {
|
||||
$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
} else {
|
||||
$price = false;
|
||||
}
|
||||
|
||||
if (!is_null($result['special']) && (float)$result['special'] >= 0) {
|
||||
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$tax_price = (float)$result['special'];
|
||||
} else {
|
||||
$special = false;
|
||||
$tax_price = (float)$result['price'];
|
||||
}
|
||||
|
||||
if ($this->config->get('config_tax')) {
|
||||
$tax = $this->currency->format($tax_price, $this->session->data['currency']);
|
||||
} else {
|
||||
$tax = false;
|
||||
}
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$rating = (int)$result['rating'];
|
||||
} else {
|
||||
$rating = false;
|
||||
}
|
||||
|
||||
$data['products'][] = array(
|
||||
'product_id' => $result['product_id'],
|
||||
'thumb' => $image,
|
||||
'name' => $result['name'],
|
||||
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'tax' => $tax,
|
||||
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
|
||||
'rating' => $result['rating'],
|
||||
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$data['sorts'] = array();
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_default'),
|
||||
'value' => 'p.sort_order-ASC',
|
||||
'href' => $this->url->link('product/special', 'sort=p.sort_order&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_asc'),
|
||||
'value' => 'pd.name-ASC',
|
||||
'href' => $this->url->link('product/special', 'sort=pd.name&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_name_desc'),
|
||||
'value' => 'pd.name-DESC',
|
||||
'href' => $this->url->link('product/special', 'sort=pd.name&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_asc'),
|
||||
'value' => 'ps.price-ASC',
|
||||
'href' => $this->url->link('product/special', 'sort=ps.price&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_price_desc'),
|
||||
'value' => 'ps.price-DESC',
|
||||
'href' => $this->url->link('product/special', 'sort=ps.price&order=DESC' . $url)
|
||||
);
|
||||
|
||||
if ($this->config->get('config_review_status')) {
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_desc'),
|
||||
'value' => 'rating-DESC',
|
||||
'href' => $this->url->link('product/special', 'sort=rating&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_rating_asc'),
|
||||
'value' => 'rating-ASC',
|
||||
'href' => $this->url->link('product/special', 'sort=rating&order=ASC' . $url)
|
||||
);
|
||||
}
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_asc'),
|
||||
'value' => 'p.model-ASC',
|
||||
'href' => $this->url->link('product/special', 'sort=p.model&order=ASC' . $url)
|
||||
);
|
||||
|
||||
$data['sorts'][] = array(
|
||||
'text' => $this->language->get('text_model_desc'),
|
||||
'value' => 'p.model-DESC',
|
||||
'href' => $this->url->link('product/special', 'sort=p.model&order=DESC' . $url)
|
||||
);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['limits'] = array();
|
||||
|
||||
$limits = array_unique(array($this->config->get('theme_' . $this->config->get('config_theme') . '_product_limit'), 25, 50, 75, 100));
|
||||
|
||||
sort($limits);
|
||||
|
||||
foreach($limits as $value) {
|
||||
$data['limits'][] = array(
|
||||
'text' => $value,
|
||||
'value' => $value,
|
||||
'href' => $this->url->link('product/special', $url . '&limit=' . $value)
|
||||
);
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['limit'])) {
|
||||
$url .= '&limit=' . $this->request->get['limit'];
|
||||
}
|
||||
|
||||
$pagination = new Pagination();
|
||||
$pagination->total = $product_total;
|
||||
$pagination->page = $page;
|
||||
$pagination->limit = $limit;
|
||||
$pagination->url = $this->url->link('product/special', $url . '&page={page}');
|
||||
|
||||
$data['pagination'] = $pagination->render();
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));
|
||||
|
||||
if (!$this->config->get('config_canonical_method')) {
|
||||
// http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
|
||||
if ($page == 1) {
|
||||
$this->document->addLink($this->url->link('product/special', ''), 'canonical');
|
||||
} elseif ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/special', ''), 'prev');
|
||||
} else {
|
||||
$this->document->addLink($this->url->link('product/special', 'page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/special', 'page=' . ($page + 1)), 'next');
|
||||
}
|
||||
} else {
|
||||
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
|
||||
$server = $this->config->get('config_ssl');
|
||||
} else {
|
||||
$server = $this->config->get('config_url');
|
||||
};
|
||||
|
||||
$request_url = rtrim($server, '/') . $this->request->server['REQUEST_URI'];
|
||||
$canonical_url = $this->url->link('product/special', '');
|
||||
|
||||
|
||||
if (($request_url != $canonical_url) || $this->config->get('config_canonical_self')) {
|
||||
$this->document->addLink($canonical_url, 'canonical');
|
||||
}
|
||||
|
||||
if ($this->config->get('config_add_prevnext')) {
|
||||
|
||||
if ($page == 2) {
|
||||
$this->document->addLink($this->url->link('product/special', ''), 'prev');
|
||||
} elseif ($page > 2) {
|
||||
$this->document->addLink($this->url->link('product/special', 'page=' . ($page - 1)), 'prev');
|
||||
}
|
||||
|
||||
if ($limit && ceil($product_total / $limit) > $page) {
|
||||
$this->document->addLink($this->url->link('product/special', 'page=' . ($page + 1)), 'next');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
$data['limit'] = $limit;
|
||||
|
||||
$data['continue'] = $this->url->link('common/home');
|
||||
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['column_right'] = $this->load->controller('common/column_right');
|
||||
$data['content_top'] = $this->load->controller('common/content_top');
|
||||
$data['content_bottom'] = $this->load->controller('common/content_bottom');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
|
||||
$this->response->setOutput($this->load->view('product/special', $data));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user