/** * Pobierz listę atrybutów * * @return array */ public function getAttributes(&$core, $idx, array $base_attribs, array $attribs, array $opts, array $filters, array $categories) { $attributes = $this->createAttribs($idx, $attribs) + $this->createOptions($idx, $opts) + (MegaFilterCore::hasFilters() ? $this->createFilters($idx, $filters) : array()) + $this->createCategories($core, $idx, $categories); /** * Dodaj podstawowe atrybuty */ if (!empty($base_attribs)) { $this->load->model('tool/image'); foreach ($base_attribs as $type => $attribute) { if (empty($attribute['enabled'])) { continue; } if (($type == 'search' || $type == 'search_oc') && (isset($this->request->get['search']) || in_array(MegaFilterCore::newInstance($this, NULL)->route(), MegaFilterCore::$_searchRoute))) { continue; } $attribute['type'] = isset($attribute['display_as_type']) ? $attribute['display_as_type'] : $type; $attribute['base_type'] = $type; $attribute['id'] = $type; $attribute['sort_order'] = (int) $attribute['sort_order']; $attribute['name'] = $this->language->get('name_' . $type); $attribute['seo_name'] = $type; $attribute['collapsed'] = empty($attribute['collapsed']) ? false : $attribute['collapsed']; $attribute['display_list_of_items'] = empty($attribute['display_list_of_items']) ? '' : $attribute['display_list_of_items']; $attribute['display_live_filter'] = empty($attribute['display_live_filter']) ? '' : $attribute['display_live_filter']; if ($type == 'manufacturers') { $attribute['options'] = $this->getManufacturers(); if (!$attribute['options']) { continue; } if (in_array($attribute['type'], array('image_list_checkbox', 'image_list_radio', 'image'))) { list($w, $h) = $this->_imageSize(); foreach ($attribute['options'] as $k => $v) { $attribute['options'][$k]['image'] = empty($v['image']) ? $this->model_tool_image->resize('no_image.jpg', $w, $h) : $this->model_tool_image->resize($v['image'], $w, $h); if (empty($attribute['options'][$k]['image'])) { $attribute['options'][$k]['image'] = $this->model_tool_image->resize('no_image.jpg', $w, $h); } } } } else { if ($type == 'stock_status') { $attribute['options'] = $this->getStockStatuses(); if (!$attribute['options']) { continue; } } } $attributes[] = $attribute; } } /** * Posortuj */ usort($attributes, array('ModelModuleMegaFilter', '_sortAttributes')); return $attributes; }
public function ajaxinfo() { $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (false !== ($idx2 = array_search('categories:tree', $baseTypes))) { unset($baseTypes[$idx2]); } echo json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); }
public function index() { $this->load->language('product/special'); $this->load->model('catalog/product'); $this->load->model('tool/image'); 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 = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = (int) $this->request->get['limit']; } else { $limit = $this->config->get('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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['heading_title'] = $this->language->get('heading_title'); $data['text_empty'] = $this->language->get('text_empty'); $data['text_quantity'] = $this->language->get('text_quantity'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_price'] = $this->language->get('text_price'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_points'] = $this->language->get('text_points'); $data['text_compare'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0); $data['text_sort'] = $this->language->get('text_sort'); $data['text_limit'] = $this->language->get('text_limit'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_list'] = $this->language->get('button_list'); $data['button_grid'] = $this->language->get('button_grid'); $data['button_continue'] = $this->language->get('button_continue'); $data['compare'] = $this->url->link('product/compare'); $data['products'] = array(); $filter_data = array('sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit); if (isset($this->request->get['category_id'])) { $filter_data['filter_category_id'] = (int) $this->request->get['category_id']; } $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('config_image_product_width'), $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } if ($this->config->get('config_customer_price') && $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'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']); } 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(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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)); // http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html if ($page == 1) { $this->document->addLink($this->url->link('product/special', '', 'SSL'), 'canonical'); } elseif ($page == 2) { $this->document->addLink($this->url->link('product/special', '', 'SSL'), 'prev'); } else { $this->document->addLink($this->url->link('product/special', 'page=' . ($page - 1), 'SSL'), 'prev'); } if ($limit && ceil($product_total / $limit) > $page) { $this->document->addLink($this->url->link('product/special', 'page=' . ($page + 1), 'SSL'), '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'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/special.tpl')) { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/special.tpl', $data)); } else { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view('default/template/product/special.tpl', $data)); } }
public function info() { $this->language->load('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 (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { //$sort = 'p.sort_order'; $sort = 'rating'; } if (isset($this->request->get['order'])) { $order = $this->request->get['order']; } else { $order = 'DESC'; } if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; } else { $limit = $this->config->get('config_catalog_limit'); } $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator')); $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id); if ($manufacturer_info) { if ($manufacturer_info['seo_title']) { $this->document->setTitle($manufacturer_info['seo_title']); } else { $this->document->setTitle($manufacturer_info['name']); } $this->document->addScript('catalog/view/javascript/jquery/jquery.total-storage.min.js'); $this->document->addScript('catalog/view/javascript/jquery.selectbox-0.2.js'); $this->document->addStyle('catalog/view/theme/res_final/stylesheet/jquery.selectbox.css'); $this->document->setDescription($manufacturer_info['meta_description']); $this->document->setKeywords($manufacturer_info['meta_keyword']); $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator')); if ($manufacturer_info['seo_h1']) { $this->data['heading_title'] = $manufacturer_info['seo_h1']; } else { $this->data['heading_title'] = $manufacturer_info['name']; } $this->data['description'] = html_entity_decode($manufacturer_info['description'], ENT_QUOTES, 'UTF-8'); $this->data['text_empty'] = $this->language->get('text_empty'); $this->data['text_quantity'] = $this->language->get('text_quantity'); $this->data['text_manufacturer'] = $this->language->get('text_manufacturer'); $this->data['text_model'] = $this->language->get('text_model'); $this->data['text_price'] = $this->language->get('text_price'); $this->data['text_tax'] = $this->language->get('text_tax'); $this->data['text_points'] = $this->language->get('text_points'); $this->data['text_compare'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0); $this->data['text_display'] = $this->language->get('text_display'); $this->data['text_list'] = $this->language->get('text_list'); $this->data['text_grid'] = $this->language->get('text_grid'); $this->data['text_sort'] = $this->language->get('text_sort'); $this->data['text_limit'] = $this->language->get('text_limit'); $this->data['button_cart'] = $this->language->get('button_cart'); $this->data['button_wishlist'] = $this->language->get('button_wishlist'); $this->data['button_compare'] = $this->language->get('button_compare'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['compare'] = $this->url->link('product/compare'); $this->data['products'] = array(); $data = array('filter_manufacturer_id' => $manufacturer_id, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit); $results = $this->model_catalog_product->getProducts($data); //Вызов метода getFoundProducts должен проводится сразу же после getProducts //только тогда он выдает правильное значения количества товаров $product_total = $this->model_catalog_product->getFoundProducts(); foreach ($results as $result) { if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) { $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } if ($this->config->get('config_customer_price') && $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'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int) $result['rating']; } else { $rating = false; } $attribute_groups = $this->model_catalog_product->getShortProductAttributes($result['product_id']); $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '..', 'price' => $price, 'special' => $special, 'attribute_groups' => $attribute_groups, 'tax' => $tax, 'rating' => $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', '&manufacturer_id=' . $result['manufacturer_id'] . '&product_id=' . $result['product_id'] . $url)); } $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $this->data['sorts'] = array(); //$this->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) // ); if ($this->config->get('config_review_status')) { $this->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)); //$this->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) // // ); } $this->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)); $this->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)); $this->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)); $this->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)); // // $this->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) // ); // // $this->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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } $this->data['limits'] = array(); $limits = array_unique(array($this->config->get('config_catalog_limit'), 25, 50, 75, 100)); sort($limits); foreach ($limits as $value) { $this->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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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->text = $this->language->get('text_pagination'); $pagination->url = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url . '&page={page}'); $this->data['pagination'] = $pagination->render(); $this->data['sort'] = $sort; $this->data['order'] = $order; $this->data['limit'] = $limit; $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/manufacturer_info.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/manufacturer_info.tpl'; } else { $this->template = 'default/template/product/manufacturer_info.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $this->data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } foreach ($this->children as $mf_child) { $mf_child = explode('/', $mf_child); $mf_child = array_pop($mf_child); $this->data[$mf_child] = ''; } $this->children = array(); $this->data['header'] = $this->data['column_left'] = $this->data['column_right'] = $this->data['content_top'] = $this->data['content_bottom'] = $this->data['footer'] = ''; } if (!empty($this->data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($this->data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $this->data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->render()); } else { $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/category', $url), 'separator' => $this->language->get('text_separator')); $this->document->setTitle($this->language->get('text_error')); $this->data['heading_title'] = $this->language->get('text_error'); $this->data['text_error'] = $this->language->get('text_error'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl'; } else { $this->template = 'default/template/error/not_found.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $this->data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } foreach ($this->children as $mf_child) { $mf_child = explode('/', $mf_child); $mf_child = array_pop($mf_child); $this->data[$mf_child] = ''; } $this->children = array(); $this->data['header'] = $this->data['column_left'] = $this->data['column_right'] = $this->data['content_top'] = $this->data['content_bottom'] = $this->data['footer'] = ''; } if (!empty($this->data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($this->data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $this->data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->render()); } }
public function getTotalProductsID($data = array()) { if ($this->customer->isLogged()) { $customer_group_id = $this->customer->getCustomerGroupId(); } else { $customer_group_id = $this->config->get('config_customer_group_id'); } $sql = "SELECT DISTINCT p.product_id"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int) $this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= '" . $this->NOW . "' AND p2s.store_id = '" . (int) $this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int) $data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int) $data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int) $filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (isset($data['available']) && $data['available']) { $sql .= " AND quantity > 0 "; } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\\s\\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $sql .= "pd.tag LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_tag'])) . "%'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int) $data['filter_manufacturer_id'] . "'"; } if (in_array(__FUNCTION__, array('getProducts', 'getTotalProducts', 'getProductSpecials', 'getTotalProductSpecials'))) { if (!empty($this->request->get['mfp']) || NULL != ($mfSettings = $this->config->get('mega_filter_settings')) && !empty($mfSettings['in_stock_default_selected'])) { if (!empty($this->request->get['mfp']) || $this->config->get('mfp_is_activated')) { $this->load->model('module/mega_filter'); $sql = MegaFilterCore::newInstance($this, $sql)->getSQL(__FUNCTION__); } } } $query = $this->db->query($sql); return $query->rows; }
public function index() { $this->load->language('product/category'); $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('tool/image'); if (isset($this->request->get['filter'])) { $filter = $this->request->get['filter']; } else { $filter = ''; } 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 = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; } else { $limit = $this->config->get('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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) { $this->document->setTitle($category_info['meta_title']); $this->document->setDescription($category_info['meta_description']); $this->document->setKeywords($category_info['meta_keyword']); $this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path']), 'canonical'); $data['heading_title'] = $category_info['name']; $data['text_refine'] = $this->language->get('text_refine'); $data['text_empty'] = $this->language->get('text_empty'); $data['text_quantity'] = $this->language->get('text_quantity'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_price'] = $this->language->get('text_price'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_points'] = $this->language->get('text_points'); $data['text_compare'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0); $data['text_sort'] = $this->language->get('text_sort'); $data['text_limit'] = $this->language->get('text_limit'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_continue'] = $this->language->get('button_continue'); $data['button_list'] = $this->language->get('button_list'); $data['button_grid'] = $this->language->get('button_grid'); // 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('config_image_category_width'), $this->config->get('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $fmSettings = $this->config->get('mega_filter_settings'); if (!empty($fmSettings['not_remember_filter_for_subcategories']) && false !== ($mfpPos = strpos($url, '&mfp='))) { $mfUrlBeforeChange = $url; $mfSt = mb_strpos($url, '&', $mfpPos + 1, 'utf-8'); $url = $mfSt === false ? '' : mb_substr($url, $mfSt, mb_strlen($url, 'utf-8'), 'utf-8'); } $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) . ')' : ''), 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)); } if (isset($mfUrlBeforeChange)) { $url = $mfUrlBeforeChange; unset($mfUrlBeforeChange); } $data['products'] = array(); $filter_data = array('filter_category_id' => $category_id, 'filter_filter' => $filter, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit); $fmSettings = $this->config->get('mega_filter_settings'); if (!empty($fmSettings['show_products_from_subcategories'])) { if (!empty($fmSettings['level_products_from_subcategories'])) { $fmLevel = (int) $fmSettings['level_products_from_subcategories']; $fmPath = explode('_', empty($this->request->get['path']) ? '' : $this->request->get['path']); if ($fmPath && count($fmPath) >= $fmLevel) { $filter_data['filter_sub_category'] = '1'; } } else { $filter_data['filter_sub_category'] = '1'; } } if (!empty($this->request->get['manufacturer_id'])) { $filter_data['filter_manufacturer_id'] = (int) $this->request->get['manufacturer_id']; } $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('config_image_product_width'), $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } if ($this->config->get('config_customer_price') && $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'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']); } 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(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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('config_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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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)); $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'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/category.tpl', $data)); } else { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view('default/template/product/category.tpl', $data)); } } else { $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $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'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data)); } else { if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $data['header'] = $data['column_left'] = $data['column_right'] = $data['content_top'] = $data['content_bottom'] = $data['footer'] = ''; } if (!empty($data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data)); } } }
public function results() { $this->data = array_merge($this->data, $this->language->load('product/search')); $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $keys = array('sort' => 'p.sort_order', 'order' => 'ASC', 'page' => 1, 'limit' => $this->config->get('config_catalog_limit')); $url = ''; foreach ($keys as $key => $keyDef) { ${$key} = isset($this->request->get[$key]) ? $this->request->get[$key] : $keyDef; if (isset($this->request->get[$key])) { $url .= '&' . $key . '=' . $this->request->get[$key]; } } $this->document->setTitle($this->language->get('heading_title')); $this->document->addScript('catalog/view/javascript/jquery/jquery.total-storage.min.js'); /** * Breadcrumb */ $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('module/mega_filter/results', $url), 'separator' => $this->language->get('text_separator')); $this->data['text_compare'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0); $this->data['compare'] = $this->url->link('product/compare'); $this->data['products'] = array(); $data = array('sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit); $product_total = $this->model_catalog_product->getTotalProducts($data); $results = $this->model_catalog_product->getProducts($data); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } else { $image = false; } if ($this->config->get('config_customer_price') && $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'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int) $result['rating']; } else { $rating = false; } $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'rating' => $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)); } $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } $this->data['sorts'] = array(); $this->data['sorts'][] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->url->link('module/mega_filter/results', 'sort=p.sort_order&order=ASC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->url->link('module/mega_filter/results', 'sort=pd.name&order=ASC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->url->link('module/mega_filter/results', 'sort=pd.name&order=DESC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->url->link('module/mega_filter/results', 'sort=p.price&order=ASC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->url->link('module/mega_filter/results', 'sort=p.price&order=DESC' . $url)); if ($this->config->get('config_review_status')) { $this->data['sorts'][] = array('text' => $this->language->get('text_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->url->link('module/mega_filter/results', 'sort=rating&order=DESC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->url->link('module/mega_filter/results', 'sort=rating&order=ASC' . $url)); } $this->data['sorts'][] = array('text' => $this->language->get('text_model_asc'), 'value' => 'p.model-ASC', 'href' => $this->url->link('module/mega_filter/results', 'sort=p.model&order=ASC' . $url)); $this->data['sorts'][] = array('text' => $this->language->get('text_model_desc'), 'value' => 'p.model-DESC', 'href' => $this->url->link('module/mega_filter/results', 'sort=p.model&order=DESC' . $url)); $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } $this->data['limits'] = array(); $limits = array_unique(array($this->config->get('config_catalog_limit'), 25, 50, 75, 100)); sort($limits); foreach ($limits as $limits) { $this->data['limits'][] = array('text' => $limits, 'value' => $limits, 'href' => $this->url->link('module/mega_filter/results', $url . '&limit=' . $limits)); } $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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->text = $this->language->get('text_pagination'); $pagination->url = $this->url->link('module/mega_filter/results', $url . '&page={page}'); $this->data['pagination'] = $pagination->render(); $this->data['sort'] = $sort; $this->data['order'] = $order; $this->data['limit'] = $limit; /** * Szablon */ if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/special.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/special.tpl'; } else { $this->template = 'default/template/product/special.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); /** * Jeśli AJAX */ if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); if (!empty($settings['show_number_of_products'])) { $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } $this->data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } $this->children = array(); $this->data['header'] = $this->data['column_left'] = $this->data['column_right'] = $this->data['content_top'] = $this->data['content_bottom'] = $this->data['footer'] = ''; } $this->response->setOutput($this->render()); }
public function index() { $this->document->setCurrent('category'); $this->language->load('product/category'); $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $this->data['page'] = $this->request->get['page']; if (isset($this->request->get['filter'])) { $filter = $this->request->get['filter']; } else { $filter = ''; } 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 = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; } else { $limit = $this->config->get('config_catalog_limit'); } $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); if (isset($this->request->get['path'])) { $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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) { $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path . $url), 'separator' => $this->language->get('text_separator')); } } } else { $category_id = 0; } $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { if ($category_info['seo_title'] && !isset($this->request->get['page'])) { $this->document->setTitle(array($category_info['seo_title'], $category_info['name'])); $GLOBALS["seotitle25"] = 'ON'; } else { $this->document->setTitle($category_info['name']); $GLOBALS["seotitle25"] = ''; } $this->document->setDescription($category_info['meta_description']); $this->document->setKeywords($category_info['meta_keyword']); //$this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/jquery.total-storage.min.js'); $this->document->addScript('catalog/view/javascript/jquery.selectbox-0.2.js'); $this->document->addStyle('catalog/view/theme/res_final/stylesheet/jquery.selectbox.css'); if ($category_info['seo_h1']) { $this->data['heading_title'] = $category_info['seo_h1']; } else { $this->data['heading_title'] = $category_info['name']; } //add----------------------- $this->data['text_cat_vuvod'] = $this->language->get('text_cat_vuvod'); $this->data['text_available'] = $this->language->get('text_available'); $this->data['text_dostavka'] = $this->language->get('text_dostavka'); $this->data['text_podzak'] = $this->language->get('text_podzak'); $this->data['text_cenyyto4'] = $this->language->get('text_cenyyto4'); $this->data['text_akcimg'] = $this->language->get('text_akcimg'); $this->data['text_buy'] = $this->language->get('text_buy'); $this->data[''] = $this->language->get(''); $this->data[''] = $this->language->get(''); $this->data[''] = $this->language->get(''); $this->data[''] = $this->language->get(''); //add----------------------- $this->data['text_refine'] = $this->language->get('text_refine'); $this->data['text_empty'] = $this->language->get('text_empty'); $this->data['text_quantity'] = $this->language->get('text_quantity'); $this->data['text_manufacturer'] = $this->language->get('text_manufacturer'); $this->data['text_model'] = $this->language->get('text_model'); $this->data['text_price'] = $this->language->get('text_price'); $this->data['text_tax'] = $this->language->get('text_tax'); $this->data['text_points'] = $this->language->get('text_points'); $this->data['text_compare'] = sprintf($this->language->get('text_compare'), isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0); $this->data['text_display'] = $this->language->get('text_display'); $this->data['text_list'] = $this->language->get('text_list'); $this->data['text_grid'] = $this->language->get('text_grid'); $this->data['text_sort'] = $this->language->get('text_sort'); $this->data['text_limit'] = $this->language->get('text_limit'); $this->data['button_cart'] = $this->language->get('button_cart'); $this->data['button_wishlist'] = $this->language->get('button_wishlist'); $this->data['button_compare'] = $this->language->get('button_compare'); $this->data['button_continue'] = $this->language->get('button_continue'); // Set the last category breadcrumb $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path']), 'separator' => $this->language->get('text_separator')); if ($category_info['image']) { $this->data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')); $this->document->setOgImage($this->data['thumb']); } else { $this->data['thumb'] = ''; } $this->data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8'); $this->data['compare'] = $this->url->link('product/compare'); $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $fmSettings = $this->config->get('mega_filter_settings'); if (!empty($fmSettings['not_remember_filter_for_subcategories']) && false !== ($mfpPos = strpos($url, '&mfp='))) { $mfUrlBeforeChange = $url; $mfSt = mb_strpos($url, '&', $mfpPos + 1, 'utf-8'); $url = $mfSt === false ? '' : mb_substr($url, $mfSt, mb_strlen($url, 'utf-8'), 'utf-8'); } $this->data['categories'] = array(); $results = $this->model_catalog_category->getCategories($category_id); foreach ($results as $result) { $data = array('filter_category_id' => $result['category_id'], 'filter_sub_category' => true); $fmSettings = $this->config->get('mega_filter_settings'); if (!empty($fmSettings['show_products_from_subcategories'])) { if (!empty($fmSettings['level_products_from_subcategories'])) { $fmLevel = (int) $fmSettings['level_products_from_subcategories']; $fmPath = explode('_', empty($this->request->get['path']) ? '' : $this->request->get['path']); if ($fmPath && count($fmPath) >= $fmLevel) { $data['filter_sub_category'] = '1'; } } else { $data['filter_sub_category'] = '1'; } } if (!empty($this->request->get['manufacturer_id'])) { $data['filter_manufacturer_id'] = (int) $this->request->get['manufacturer_id']; } if (!empty($fmSettings['in_stock_default_selected'])) { $this->data['column_left'] = $this->getChild('common/column_left'); $this->data['column_right'] = $this->getChild('common/column_right'); $this->data['content_top'] = $this->getChild('common/content_top'); $this->data['mfp_column_left'] = true; $this->data['mfp_column_right'] = true; $this->data['mfp_content_top'] = true; } $product_total = $this->model_catalog_product->getTotalProducts($data); if ($product_total > 0) { $this->data['categories'][] = array('name' => $result['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url), 'thumb' => $this->model_tool_image->resize($result['image'] == '' ? 'no_image.jpg' : $result['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))); } } if (isset($mfUrlBeforeChange)) { $url = $mfUrlBeforeChange; unset($mfUrlBeforeChange); } $this->data['products'] = array(); $data = array('filter_category_id' => $category_id, 'filter_filter' => $filter, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit); $results = $this->model_catalog_product->getProducts($data); //Вызов метода getFoundProducts должен проводится сразу же после getProducts //только тогда он выдает правильное значения количества товаров $product_total = $this->model_catalog_product->getFoundProducts(); foreach ($results as $result) { if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) { $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } $attribute_groups = $this->model_catalog_product->getShortProductAttributes($result['product_id']); if ($result['quantity'] <= 0) { $attribute_groups2 = $this->model_catalog_product->getProductAttributes($result['product_id']); foreach ($attribute_groups2 as $attribute_group) { foreach ($attribute_group as $prop) { foreach ($prop as $key => $attribute) { if ($attribute['name'] == $this->language->get('text_term')) { $days = $attribute['text']; } } } } } if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) { //$price = $this->tax->calculate(round($result['price']), $result['tax_class_id'], $this->config->get('config_tax')); $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((double) $result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((double) $result['special'] ? $result['special'] : $result['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int) $result['rating']; } else { $rating = false; } $compare_link = '<a href="javascript:;" onclick="addToCompare(\'' . $result['product_id'] . '\', this);">' . $this->language->get('text_addtocompare') . '</a>'; if (isset($this->session->data['compare'])) { foreach ($this->session->data['compare'] as $prod_id) { if ($prod_id == $result['product_id']) { $compare_link = '<a href="' . $pref_lang . '/compare-products/">' . $this->language->get('text_intocompare') . '</a>'; break; } } } $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '..', 'price' => $price, 'special' => $special, 'compare_link' => $compare_link, 'quantity' => $result['quantity'], 'days' => $days, 'unit' => $result['unit'], 'tax' => $tax, 'rating' => $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'attribute_groups' => $attribute_groups, 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)); } $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $this->data['sorts'] = array(); //$this->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) // ); if ($this->config->get('config_review_status')) { $this->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)); //$this->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) // ); } // $this->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) // ); // $this->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) // ); $this->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)); $this->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)); //print_r($this->data['sorts']); // // $this->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) // ); // // $this->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 (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $this->data['limits'] = array(); $limits = array_unique(array($this->config->get('config_catalog_limit'), 25, 50, 75, 100)); sort($limits); foreach ($limits as $value) { $this->data['limits'][] = array('text' => $value, 'value' => $value, 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&limit=' . $value)); } $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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->text = $this->language->get('text_pagination'); $pagination->url = $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page={page}'); //$this->data['pag'] = $product_total . $page . $limit; $this->data['pagination'] = $pagination->render(); $this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page=' . $pagination->page), 'canonical'); if ($pagination->limit && ceil($pagination->total / $pagination->limit) > $pagination->page) { $this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page=' . ($pagination->page + 1)), 'next'); } if ($pagination->page > 1) { $this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page=' . ($pagination->page - 1)), 'prev'); } $this->data['sort'] = $sort; $this->data['order'] = $order; $this->data['limit'] = $limit; $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/category.tpl'; } else { $this->template = 'default/template/product/category.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $this->data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } foreach ($this->children as $mf_child) { $mf_child = explode('/', $mf_child); $mf_child = array_pop($mf_child); $this->data[$mf_child] = ''; } $this->children = array(); $this->data['header'] = $this->data['column_left'] = $this->data['column_right'] = $this->data['content_top'] = $this->data['content_bottom'] = $this->data['footer'] = ''; } if (!empty($this->data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($this->data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $this->data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->render()); } else { $url = ''; if (!empty($this->request->get['mfp'])) { $url .= '&mfp=' . $this->request->get['mfp']; } 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']; } $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/category', $url), 'separator' => $this->language->get('text_separator')); $this->document->setTitle($this->language->get('text_error')); $this->data['heading_title'] = $this->language->get('text_error'); $this->data['text_error'] = $this->language->get('text_error'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl'; } else { $this->template = 'default/template/error/not_found.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); if (isset($this->request->get['mfilterAjax'])) { $settings = $this->config->get('mega_filter_settings'); $baseTypes = array('stock_status', 'manufacturers', 'rating', 'attributes', 'price', 'options', 'filters'); if (isset($this->request->get['mfilterBTypes'])) { $baseTypes = explode(',', $this->request->get['mfilterBTypes']); } if (!empty($settings['calculate_number_of_products']) || in_array('categories:tree', $baseTypes)) { if (empty($settings['calculate_number_of_products'])) { $baseTypes = array('categories:tree'); } $this->load->model('module/mega_filter'); $idx = 0; if (isset($this->request->get['mfilterIdx'])) { $idx = (int) $this->request->get['mfilterIdx']; } $this->data['mfilter_json'] = json_encode(MegaFilterCore::newInstance($this, NULL)->getJsonData($baseTypes, $idx)); } foreach ($this->children as $mf_child) { $mf_child = explode('/', $mf_child); $mf_child = array_pop($mf_child); $this->data[$mf_child] = ''; } $this->children = array(); $this->data['header'] = $this->data['column_left'] = $this->data['column_right'] = $this->data['content_top'] = $this->data['content_bottom'] = $this->data['footer'] = ''; } if (!empty($this->data['breadcrumbs']) && !empty($this->request->get['mfp'])) { foreach ($this->data['breadcrumbs'] as $mfK => $mfBreadcrumb) { $mfReplace = preg_replace('/path\\[[^\\]]+\\],?/', '', $this->request->get['mfp']); $mfFind = mb_strpos($mfBreadcrumb['href'], '?mfp=', 0, 'utf-8') !== false ? '?mfp=' : '&mfp='; $this->data['breadcrumbs'][$mfK]['href'] = str_replace(array($mfFind . $this->request->get['mfp'], '&mfp=' . $this->request->get['mfp'], $mfFind . urlencode($this->request->get['mfp']), '&mfp=' . urlencode($this->request->get['mfp'])), $mfReplace ? $mfFind . $mfReplace : '', $mfBreadcrumb['href']); } } $this->response->setOutput($this->render()); } }