Skip to content

Commit

Permalink
Обновлен coolfilter
Browse files Browse the repository at this point in the history
  • Loading branch information
ocshop committed Jan 15, 2015
1 parent 684588d commit d08350e
Show file tree
Hide file tree
Showing 22 changed files with 4,583 additions and 121 deletions.
45 changes: 30 additions & 15 deletions upload/catalog/controller/module/coolfilter.php
Expand Up @@ -20,7 +20,13 @@ protected function index($setting) {
$this->document->addStyle('catalog/view/theme/default/stylesheet/coolfilter.css');
}

$this->document->addScript('catalog/view/javascript/jquery/ionrange/js/ion-rangeSlider/ion.rangeSlider.js');
$this->document->addStyle('catalog/view/javascript/jquery/ionrange/css/ion.rangeSlider.css');
$this->document->addStyle('catalog/view/javascript/jquery/ionrange/css/ion.rangeSlider.skinModern.css');


// Получить id группы фильтра

$coolfilter_group_id = $setting['coolfilter_group_id'];

// Получить id категории
Expand Down Expand Up @@ -128,10 +134,9 @@ private function getcoolfilterItemNames($coolfilter_types, $categories_id) {

if (isset($coolfilter_types['price'])) {
$price_data = $this->getDataForcoolfilter($coolfilter_types['price'], $categories_id_to_string, 'price');

$price_data['price']['coolfilters'][0]['value'] = floor($this->currency->format($price_data['price']['coolfilters'][0]['value'], '', '', false));
$price_data['price']['coolfilters'][1]['value'] = ceil($this->currency->format($price_data['price']['coolfilters'][1]['value'], '', '', false));

$coolfilterItemNames += $price_data;

}
Expand Down Expand Up @@ -200,15 +205,16 @@ private function getDataForcoolfilter($coolfilter_types, $categories_id_to_strin
$image = $no_image;
}


$coolfilterItemNames[$index]['coolfilters'][] = array('name' => $item_name['name'],
'href' => $data['href'],
'value' => $item_name['value'],
'key' => $option_key,
'active' => $data['active'],
'count' => $data['count'],
'view_count' => ($data['count'] != '') ? '(' . $data['count'] . ')' : '',
'image' => $image );
if (($data['count'] > 0) || ($option_key == 'p') ){
$coolfilterItemNames[$index]['coolfilters'][] = array('name' => $item_name['name'],
'href' => $data['href'],
'value' => $item_name['value'],
'key' => $option_key,
'active' => $data['active'],
'count' => $data['count'],
'view_count' => ($data['count'] != '') ? '(' . $data['count'] . ')' : '',
'image' => $image );
};
}


Expand Down Expand Up @@ -273,11 +279,17 @@ private function getDataForcoolfilterValue($url, $option_key, $option_value) {

// Получение уже существующих параметров фильтра
private function getcoolfilterURLParams($coolfilter = 0, $option_key, $option_value) {


/*
if ($option_key == 'p') {
print_r('</br>');
print_r($coolfilter);
print_r('</br>');
print_r($option_value);
};
*/
$sep_par = ';'; // разделитель пар опций -> значений: opt1:val1,val2,val3;opt2:val1,val2,val3 ...
$sep_opt = ':'; // разделитель внутри пары опция -> значения: opt1:val1,val2,val3 ...
$sep_val = ','; // разделитель для параметров опции: val1,val2,val3 ...
$sep_val = '|'; // разделитель для параметров опции: val1,val2,val3 ...
$out = '';

if ($coolfilter) {
Expand Down Expand Up @@ -309,11 +321,14 @@ private function getcoolfilterURLParams($coolfilter = 0, $option_key, $option_va
$options[] = $option_key . $sep_opt . $option_value;
}
$out = implode($sep_par, $options);

}
else {
$out .= $option_key . $sep_opt . $option_value;

}

$out = mb_convert_encoding($out, 'utf-8', mb_detect_encoding($out));

return $out;
}
Expand Down
22 changes: 18 additions & 4 deletions upload/catalog/model/catalog/coolfilter.php
Expand Up @@ -52,7 +52,7 @@ public function getManufacterItemNames($categories_id) {

if (!$cache_data && !is_array($cache_data)) {

$query = $this->db->query("SELECT DISTINCT mnf.manufacturer_id as value, mnf.name, mnf.image FROM `" . DB_PREFIX . "manufacturer` mnf LEFT JOIN `" . DB_PREFIX . "product` as prd ON (mnf.manufacturer_id = prd.manufacturer_id) WHERE prd.product_id IN (SELECT product_id FROM `" . DB_PREFIX . "product_to_category` WHERE category_id IN (" . $this->db->escape($categories_id) . ")) ORDER BY mnf.name");
$query = $this->db->query("SELECT DISTINCT mnf.manufacturer_id as value, mnf.name, mnf.image FROM `" . DB_PREFIX . "manufacturer` mnf LEFT JOIN `" . DB_PREFIX . "product` as prd ON (mnf.manufacturer_id = prd.manufacturer_id) WHERE prd.product_id IN (SELECT product_id FROM `" . DB_PREFIX . "product_to_category` WHERE prd.status != '0' AND category_id IN (" . $this->db->escape($categories_id) . ")) ORDER BY mnf.name");

$manufacters = $query->rows;

Expand All @@ -70,10 +70,19 @@ public function getOptionItemNames($coolfilter_options_id, $categories_id) {

$categories_hash = md5($categories_id);
$cache_data = $this->cache->get('get_option_items_names.' . $coolfilter_options_id . '.' . $categories_hash . '.' . $this->config->get('config_language_id'));

$cache_data = null;
if (!$cache_data && !is_array($cache_data)) {

$query = $this->db->query("SELECT DISTINCT prd.option_value_id as value, prd.option_id as id, opt.name, opv.image FROM `" . DB_PREFIX . "product_option_value` prd LEFT JOIN `" . DB_PREFIX . "option_value_description` as opt ON (opt.option_value_id=prd.option_value_id AND opt.option_value_id=prd.option_value_id) LEFT JOIN `" . DB_PREFIX . "option_value` as opv ON (opv.option_value_id=prd.option_value_id) WHERE prd.option_id IN (" . $this->db->escape($coolfilter_options_id) . ") AND opt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND prd.product_id IN (SELECT product_id FROM `" . DB_PREFIX . "product_to_category` WHERE category_id IN (" . $this->db->escape($categories_id) . ")) ORDER BY opt.name");
$query = $this->db->query("SELECT DISTINCT prd.option_value_id as value, prd.option_id as id, opt.name, opv.image
FROM `" . DB_PREFIX . "product_option_value` prd LEFT JOIN `" . DB_PREFIX . "option_value_description` as opt ON (opt.option_value_id=prd.option_value_id
AND opt.option_value_id=prd.option_value_id)
LEFT JOIN `" . DB_PREFIX . "option_value` as opv ON (opv.option_value_id=prd.option_value_id)
WHERE prd.option_id IN (" . $this->db->escape($coolfilter_options_id) . ") AND opt.language_id = '" . (int)$this->config->get('config_language_id') . "'
AND prd.product_id IN (SELECT p2c.product_id
FROM `" . DB_PREFIX . "product_to_category` p2c
LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)
WHERE p.status != 0 AND p2c.category_id IN (" . $this->db->escape($categories_id) . "))
ORDER BY opt.name");

$options = $query->rows;
$this->cache->get('get_option_items_names.' . $coolfilter_options_id . '.' . $categories_hash . '.' . $this->config->get('config_language_id'), $options);
Expand All @@ -88,7 +97,12 @@ public function getOptionItemNames($coolfilter_options_id, $categories_id) {

public function getAttributeItemNames($coolfilter_attributes_id, $categories_id) {

$query = $this->db->query("SELECT DISTINCT text as value, attribute_id as id, text as name FROM `" . DB_PREFIX . "product_attribute` WHERE attribute_id IN (" . $this->db->escape($coolfilter_attributes_id) . ") AND language_id = '" . (int)$this->config->get('config_language_id') . "' AND product_id IN (SELECT product_id FROM `" . DB_PREFIX . "product_to_category` WHERE category_id IN (" . $this->db->escape($categories_id) . ")) ORDER BY text");
$query = $this->db->query("SELECT DISTINCT text as value, pa.attribute_id as id, text as name
FROM `" . DB_PREFIX . "product_attribute` pa WHERE pa.attribute_id IN (" . $this->db->escape($coolfilter_attributes_id) . ")
AND language_id = '" . (int)$this->config->get('config_language_id') . "'
AND pa.product_id IN (SELECT p2c.product_id FROM `" . DB_PREFIX . "product_to_category` p2c
LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)
WHERE p.status != 0 AND category_id IN (" . $this->db->escape($categories_id) . ")) ORDER BY text=0, -text DESC, text");

return $query->rows;

Expand Down

0 comments on commit d08350e

Please sign in to comment.