// blocklayered is now available for PS 1.4 and 1.5.
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10715 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
* @version Release: $Revision$
|
* @version Release: $Revision: 10659 $
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registred Trademark & Property of PrestaShop SA
|
* International Registred Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
@@ -33,11 +33,13 @@ class BlockLayered extends Module
|
|||||||
private $products;
|
private $products;
|
||||||
private $nbr_products;
|
private $nbr_products;
|
||||||
|
|
||||||
|
private $page = 1;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->name = 'blocklayered';
|
$this->name = 'blocklayered';
|
||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
$this->version = 1.5;
|
$this->version = '1.7';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
|
||||||
@@ -45,6 +47,9 @@ class BlockLayered extends Module
|
|||||||
|
|
||||||
$this->displayName = $this->l('Layered navigation block');
|
$this->displayName = $this->l('Layered navigation block');
|
||||||
$this->description = $this->l('Displays a block with layered navigation filters.');
|
$this->description = $this->l('Displays a block with layered navigation filters.');
|
||||||
|
|
||||||
|
if ((int)Tools::getValue('p'))
|
||||||
|
$this->page = (int)Tools::getValue('p');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
@@ -60,6 +65,7 @@ class BlockLayered extends Module
|
|||||||
{
|
{
|
||||||
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 0);
|
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 0);
|
||||||
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1);
|
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1);
|
||||||
|
Configuration::updateValue('PS_LAYERED_FULL_TREE', 1);
|
||||||
|
|
||||||
$this->rebuildLayeredStructure();
|
$this->rebuildLayeredStructure();
|
||||||
$this->rebuildLayeredCache();
|
$this->rebuildLayeredCache();
|
||||||
@@ -89,6 +95,7 @@ class BlockLayered extends Module
|
|||||||
/* Delete all configurations */
|
/* Delete all configurations */
|
||||||
Configuration::deleteByName('PS_LAYERED_HIDE_0_VALUES');
|
Configuration::deleteByName('PS_LAYERED_HIDE_0_VALUES');
|
||||||
Configuration::deleteByName('PS_LAYERED_SHOW_QTIES');
|
Configuration::deleteByName('PS_LAYERED_SHOW_QTIES');
|
||||||
|
Configuration::deleteByName('PS_LAYERED_FULL_TREE');
|
||||||
Configuration::deleteByName('PS_LAYERED_INDEXED');
|
Configuration::deleteByName('PS_LAYERED_INDEXED');
|
||||||
|
|
||||||
Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index');
|
Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index');
|
||||||
@@ -1057,11 +1064,22 @@ class BlockLayered extends Module
|
|||||||
if (!empty($metaKeyWordsComplement))
|
if (!empty($metaKeyWordsComplement))
|
||||||
$smarty->assign('meta_keywords', rtrim($categoryTitle.', '.$metaKeyWordsComplement.', '.$categoryMetas['meta_keywords'], ', '));
|
$smarty->assign('meta_keywords', rtrim($categoryTitle.', '.$metaKeyWordsComplement.', '.$categoryMetas['meta_keywords'], ', '));
|
||||||
|
|
||||||
$this->context->controller->addJS(($this->_path).'blocklayered.js');
|
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||||
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
|
{
|
||||||
$this->context->controller->addCSS(_PS_CSS_DIR_.'jquery-ui-1.8.10.custom.css', 'all');
|
$this->context->controller->addJS(($this->_path).'blocklayered.js');
|
||||||
$this->context->controller->addCSS(($this->_path).'blocklayered.css', 'all');
|
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
|
||||||
$this->context->controller->addCSS(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
|
$this->context->controller->addJQueryUI('ui.slider');
|
||||||
|
$this->context->controller->addCSS(($this->_path).'blocklayered.css', 'all');
|
||||||
|
$this->context->controller->addJQueryPlugin('scrollTo');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Tools::addJS(($this->_path).'blocklayered.js');
|
||||||
|
Tools::addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
|
||||||
|
Tools::addCSS(_PS_CSS_DIR_.'jquery-ui-1.8.10.custom.css', 'all');
|
||||||
|
Tools::addCSS(($this->_path).'blocklayered.css', 'all');
|
||||||
|
Tools::addJS(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookFooter($params)
|
public function hookFooter($params)
|
||||||
@@ -1190,6 +1208,7 @@ class BlockLayered extends Module
|
|||||||
{
|
{
|
||||||
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', Tools::getValue('ps_layered_hide_0_values'));
|
Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', Tools::getValue('ps_layered_hide_0_values'));
|
||||||
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', Tools::getValue('ps_layered_show_qties'));
|
Configuration::updateValue('PS_LAYERED_SHOW_QTIES', Tools::getValue('ps_layered_show_qties'));
|
||||||
|
Configuration::updateValue('PS_LAYERED_FULL_TREE', Tools::getValue('ps_layered_full_tree'));
|
||||||
|
|
||||||
$html .= '
|
$html .= '
|
||||||
<div class="conf">
|
<div class="conf">
|
||||||
@@ -1721,6 +1740,15 @@ class BlockLayered extends Module
|
|||||||
'.$this->l('No').' <input type="radio" name="ps_layered_show_qties" value="0" '.(!Configuration::get('PS_LAYERED_SHOW_QTIES') ? 'checked="checked"' : '').' />
|
'.$this->l('No').' <input type="radio" name="ps_layered_show_qties" value="0" '.(!Configuration::get('PS_LAYERED_SHOW_QTIES') ? 'checked="checked"' : '').' />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: right;">'.$this->l('Show products from subcategories').'</td>
|
||||||
|
<td>
|
||||||
|
<img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />
|
||||||
|
'.$this->l('Yes').' <input type="radio" name="ps_layered_full_tree" value="1" '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'checked="checked"' : '').' />
|
||||||
|
<img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" style="margin-left: 10px;" />
|
||||||
|
'.$this->l('No').' <input type="radio" name="ps_layered_full_tree" value="0" '.(!Configuration::get('PS_LAYERED_FULL_TREE') ? 'checked="checked"' : '').' />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p style="text-align: center;"><input type="submit" class="button" name="submitLayeredSettings" value="'.$this->l('Save configuration').'" /></p>
|
<p style="text-align: center;"><input type="submit" class="button" name="submitLayeredSettings" value="'.$this->l('Save configuration').'" /></p>
|
||||||
</form>
|
</form>
|
||||||
@@ -1752,7 +1780,9 @@ class BlockLayered extends Module
|
|||||||
{
|
{
|
||||||
$urlParameters = explode('-', $urlAttribute);
|
$urlParameters = explode('-', $urlAttribute);
|
||||||
$attributeName = array_shift($urlParameters);
|
$attributeName = array_shift($urlParameters);
|
||||||
if (in_array($attributeName, array('price', 'weight')))
|
if ($attributeName == 'page')
|
||||||
|
$this->page = (int)$urlParameters[0];
|
||||||
|
else if (in_array($attributeName, array('price', 'weight')))
|
||||||
$selectedFilters[$attributeName] = array($urlParameters[0], $urlParameters[1]);
|
$selectedFilters[$attributeName] = array($urlParameters[0], $urlParameters[1]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1833,10 +1863,18 @@ class BlockLayered extends Module
|
|||||||
|
|
||||||
$parent = new Category((int)$id_parent);
|
$parent = new Category((int)$id_parent);
|
||||||
if (!count($selectedFilters['category']))
|
if (!count($selectedFilters['category']))
|
||||||
$queryFiltersFrom .= ' INNER JOIN '._DB_PREFIX_.'category_product cp
|
{
|
||||||
ON p.id_product = cp.id_product
|
if (Configuration::get('PS_LAYERED_FULL_TREE'))
|
||||||
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category
|
$queryFiltersFrom .= ' INNER JOIN '._DB_PREFIX_.'category_product cp
|
||||||
AND c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.')';
|
ON p.id_product = cp.id_product
|
||||||
|
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND
|
||||||
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).')';
|
||||||
|
else
|
||||||
|
$queryFiltersFrom .= ' INNER JOIN '._DB_PREFIX_.'category_product cp
|
||||||
|
ON p.id_product = cp.id_product
|
||||||
|
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category
|
||||||
|
AND c.id_category = '.(int)$id_parent.')';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($selectedFilters as $key => $filterValues)
|
foreach ($selectedFilters as $key => $filterValues)
|
||||||
{
|
{
|
||||||
@@ -1931,24 +1969,31 @@ class BlockLayered extends Module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$idCurrency = Currency::getCurrent()->id;
|
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||||
|
$idCurrency = (int)Context::getContext()->currency->id;
|
||||||
|
else
|
||||||
|
$idCurrency = (int)Currency::getCurrent()->id;
|
||||||
|
|
||||||
$priceFilterQueryIn = ''; // All products with price range between price filters limits
|
$priceFilterQueryIn = ''; // All products with price range between price filters limits
|
||||||
$priceFilterQueryOut = ''; // All products with a price filters limit on it price range
|
$priceFilterQueryOut = ''; // All products with a price filters limit on it price range
|
||||||
if (isset($priceFilter) && $priceFilter)
|
if (isset($priceFilter) && $priceFilter)
|
||||||
{
|
{
|
||||||
$priceFilterQueryIn = 'INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
$priceFilterQueryIn = 'INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
||||||
ON psi.price_min >= '.(int)$priceFilter['min'].'
|
ON
|
||||||
|
(
|
||||||
|
psi.price_min >= '.(int)$priceFilter['min'].'
|
||||||
AND psi.price_max <= '.(int)$priceFilter['max'].'
|
AND psi.price_max <= '.(int)$priceFilter['max'].'
|
||||||
AND psi.`id_product` = p.`id_product`
|
AND psi.`id_product` = p.`id_product`
|
||||||
AND psi.`id_currency` = '.(int)$idCurrency;
|
AND psi.`id_currency` = '.$idCurrency.'
|
||||||
|
)';
|
||||||
|
|
||||||
$priceFilterQueryOut = 'INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
$priceFilterQueryOut = 'INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
||||||
ON
|
ON
|
||||||
((psi.price_min <= '.(int)$priceFilter['min'].' AND psi.price_max >= '.(int)$priceFilter['min'].')
|
((psi.price_min < '.(int)$priceFilter['min'].' AND psi.price_max > '.(int)$priceFilter['min'].')
|
||||||
OR
|
OR
|
||||||
(psi.price_max >= '.(int)$priceFilter['max'].' AND psi.price_min <= '.(int)$priceFilter['max'].'))
|
(psi.price_max > '.(int)$priceFilter['max'].' AND psi.price_min < '.(int)$priceFilter['max'].'))
|
||||||
AND psi.`id_product` = p.`id_product`
|
AND psi.`id_product` = p.`id_product`
|
||||||
AND psi.`id_currency` = '.(int)$idCurrency;
|
AND psi.`id_currency` = '.$idCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allProductsOut = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
$allProductsOut = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||||
@@ -1997,10 +2042,12 @@ class BlockLayered extends Module
|
|||||||
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
|
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
|
||||||
LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
|
LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
|
||||||
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
||||||
WHERE p.`active` = 1 AND c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.' AND pl.id_lang = '.(int)$cookie->id_lang.'
|
WHERE p.`active` = 1 AND
|
||||||
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).'
|
||||||
|
AND pl.id_lang = '.(int)$cookie->id_lang.'
|
||||||
AND p.id_product IN ('.implode(',', $productIdList).')'
|
AND p.id_product IN ('.implode(',', $productIdList).')'
|
||||||
.' GROUP BY p.id_product ORDER BY '.Tools::getProductsOrder('by', Tools::getValue('orderby'), true).' '.Tools::getProductsOrder('way', Tools::getValue('orderway')).
|
.' GROUP BY p.id_product ORDER BY '.Tools::getProductsOrder('by', Tools::getValue('orderby'), true).' '.Tools::getProductsOrder('way', Tools::getValue('orderway')).
|
||||||
' LIMIT '.(((int)Tools::getValue('p', 1) - 1) * $n.','.$n));
|
' LIMIT '.(((int)$this->page - 1) * $n.','.$n));
|
||||||
}
|
}
|
||||||
return $this->products;
|
return $this->products;
|
||||||
}
|
}
|
||||||
@@ -2010,6 +2057,11 @@ class BlockLayered extends Module
|
|||||||
global $cookie;
|
global $cookie;
|
||||||
static $cache = null;
|
static $cache = null;
|
||||||
|
|
||||||
|
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||||
|
$currency = Context::getContext()->currency;
|
||||||
|
else
|
||||||
|
$currency = Currency::getCurrent();
|
||||||
|
|
||||||
if (is_array($cache))
|
if (is_array($cache))
|
||||||
return $cache;
|
return $cache;
|
||||||
|
|
||||||
@@ -2055,7 +2107,8 @@ class BlockLayered extends Module
|
|||||||
FROM '._DB_PREFIX_.'product p ';
|
FROM '._DB_PREFIX_.'product p ';
|
||||||
$sqlQuery['join'] = '
|
$sqlQuery['join'] = '
|
||||||
INNER JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
INNER JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
||||||
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.') ';
|
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND
|
||||||
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).') ';
|
||||||
$sqlQuery['where'] = 'WHERE p.`active` = 1 ';
|
$sqlQuery['where'] = 'WHERE p.`active` = 1 ';
|
||||||
$sqlQuery['group'] = ' GROUP BY p.id_product ';
|
$sqlQuery['group'] = ' GROUP BY p.id_product ';
|
||||||
break;
|
break;
|
||||||
@@ -2067,8 +2120,8 @@ class BlockLayered extends Module
|
|||||||
INNER JOIN `'._DB_PREFIX_.'category` c ON (c.id_category = cp.id_category)
|
INNER JOIN `'._DB_PREFIX_.'category` c ON (c.id_category = cp.id_category)
|
||||||
INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product AND p.active = 1)
|
INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product AND p.active = 1)
|
||||||
INNER JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) ';
|
INNER JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) ';
|
||||||
$sqlQuery['where'] = '
|
$sqlQuery['where'] = 'WHERE
|
||||||
WHERE c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.' ';
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' ';
|
||||||
$sqlQuery['group'] = ' GROUP BY p.id_manufacturer ';
|
$sqlQuery['group'] = ' GROUP BY p.id_manufacturer ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2100,7 +2153,8 @@ class BlockLayered extends Module
|
|||||||
AND p.id_product IN (
|
AND p.id_product IN (
|
||||||
SELECT id_product
|
SELECT id_product
|
||||||
FROM '._DB_PREFIX_.'category_product cp
|
FROM '._DB_PREFIX_.'category_product cp
|
||||||
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.')) ';
|
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND
|
||||||
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).')) ';
|
||||||
$sqlQuery['group'] = '
|
$sqlQuery['group'] = '
|
||||||
GROUP BY lpa.id_attribute
|
GROUP BY lpa.id_attribute
|
||||||
ORDER BY id_attribute_group, id_attribute ';
|
ORDER BY id_attribute_group, id_attribute ';
|
||||||
@@ -2125,7 +2179,8 @@ class BlockLayered extends Module
|
|||||||
AND p.id_product IN (
|
AND p.id_product IN (
|
||||||
SELECT id_product
|
SELECT id_product
|
||||||
FROM '._DB_PREFIX_.'category_product cp
|
FROM '._DB_PREFIX_.'category_product cp
|
||||||
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright.')) ';
|
INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND
|
||||||
|
'.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).')) ';
|
||||||
$sqlQuery['group'] = 'GROUP BY fv.id_feature_value ';
|
$sqlQuery['group'] = 'GROUP BY fv.id_feature_value ';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2184,7 +2239,7 @@ class BlockLayered extends Module
|
|||||||
{
|
{
|
||||||
case 'price':
|
case 'price':
|
||||||
$priceArray = array('type_lite' => 'price', 'type' => 'price', 'id_key' => 0, 'name' => $this->l('Price'),
|
$priceArray = array('type_lite' => 'price', 'type' => 'price', 'id_key' => 0, 'name' => $this->l('Price'),
|
||||||
'slider' => true, 'max' => '0', 'min' => null, 'values' => array ('1' => 0), 'unit' => Currency::getCurrent()->sign);
|
'slider' => true, 'max' => '0', 'min' => null, 'values' => array ('1' => 0), 'unit' => $currency->sign);
|
||||||
if (isset($products) && $products)
|
if (isset($products) && $products)
|
||||||
foreach ($products as $product)
|
foreach ($products as $product)
|
||||||
{
|
{
|
||||||
@@ -2378,6 +2433,7 @@ class BlockLayered extends Module
|
|||||||
|
|
||||||
//generate SEO link
|
//generate SEO link
|
||||||
$paramSelected = '';
|
$paramSelected = '';
|
||||||
|
$param_product_url = '';
|
||||||
$optionCheckedArray = array();
|
$optionCheckedArray = array();
|
||||||
$paramGroupSelectedArray = array();
|
$paramGroupSelectedArray = array();
|
||||||
$titleValues = array();
|
$titleValues = array();
|
||||||
@@ -2412,8 +2468,15 @@ class BlockLayered extends Module
|
|||||||
$paramSelected .= '/'.str_replace('-', '_', Tools::link_rewrite($filterName)).$paramGroupSelected;
|
$paramSelected .= '/'.str_replace('-', '_', Tools::link_rewrite($filterName)).$paramGroupSelected;
|
||||||
$optionCheckedArray[Tools::link_rewrite($filterName)] = $paramGroupSelected;
|
$optionCheckedArray[Tools::link_rewrite($filterName)] = $paramGroupSelected;
|
||||||
}
|
}
|
||||||
|
// select only attribute and group attribute to display an unique product combination link
|
||||||
|
if (!empty($paramGroupSelected) && $typeFilter['type'] == 'id_attribute_group')
|
||||||
|
$param_product_url .= '/'.str_replace('-', '_', Tools::link_rewrite($filterName)).$paramGroupSelected;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->page > 1)
|
||||||
|
$paramSelected .= '/page-'.$this->page;
|
||||||
|
|
||||||
$blackList = array('weight','price');
|
$blackList = array('weight','price');
|
||||||
$nofollow = false;
|
$nofollow = false;
|
||||||
foreach ($filterBlocks as &$typeFilter)
|
foreach ($filterBlocks as &$typeFilter)
|
||||||
@@ -2477,9 +2540,18 @@ class BlockLayered extends Module
|
|||||||
foreach ($selectedFilters as $filters)
|
foreach ($selectedFilters as $filters)
|
||||||
$nFilters += count($filters);
|
$nFilters += count($filters);
|
||||||
|
|
||||||
$cache = array('layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'), 'id_category_layered' => (int)$id_parent,
|
$cache = array(
|
||||||
'selected_filters' => $selectedFilters, 'n_filters' => (int)$nFilters, 'nbr_filterBlocks' => count($filterBlocks), 'filters' => $filterBlocks,
|
'layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'),
|
||||||
'title_values' => $titleValues, 'current_friendly_url' => htmlentities($paramSelected), 'nofollow' => !empty($paramSelected) || $nofollow);
|
'id_category_layered' => (int)$id_parent,
|
||||||
|
'selected_filters' => $selectedFilters,
|
||||||
|
'n_filters' => (int)$nFilters,
|
||||||
|
'nbr_filterBlocks' => count($filterBlocks),
|
||||||
|
'filters' => $filterBlocks,
|
||||||
|
'title_values' => $titleValues,
|
||||||
|
'current_friendly_url' => htmlentities($paramSelected),
|
||||||
|
'param_product_url' => htmlentities($param_product_url),
|
||||||
|
'nofollow' => !empty($paramSelected) || $nofollow
|
||||||
|
);
|
||||||
|
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
@@ -2515,18 +2587,19 @@ class BlockLayered extends Module
|
|||||||
|
|
||||||
private static function getPriceFilterSubQuery($filterValue)
|
private static function getPriceFilterSubQuery($filterValue)
|
||||||
{
|
{
|
||||||
$idCurrency = (int)Currency::getCurrent()->id;
|
if (version_compare(_PS_VERSION_,'1.5','>'))
|
||||||
|
$idCurrency = (int)Context::getContext()->currency->id;
|
||||||
|
else
|
||||||
|
$idCurrency = (int)Currency::getCurrent()->id;
|
||||||
$priceFilterQuery = '';
|
$priceFilterQuery = '';
|
||||||
if (isset($filterValue) && $filterValue)
|
if (isset($filterValue) && $filterValue)
|
||||||
{
|
{
|
||||||
$idCurrency = Currency::getCurrent()->id;
|
|
||||||
$priceFilterQuery = '
|
$priceFilterQuery = '
|
||||||
INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$idCurrency.'
|
INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$idCurrency.'
|
||||||
AND psi.price_min <= '.(int)$filterValue[1].' AND psi.price_max >= '.(int)$filterValue[0].') ';
|
AND psi.price_min <= '.(int)$filterValue[1].' AND psi.price_max >= '.(int)$filterValue[0].') ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$idCurrency = Currency::getCurrent()->id;
|
|
||||||
$priceFilterQuery = '
|
$priceFilterQuery = '
|
||||||
INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi
|
||||||
ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$idCurrency.') ';
|
ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$idCurrency.') ';
|
||||||
@@ -2851,7 +2924,7 @@ class BlockLayered extends Module
|
|||||||
$range = 2; /* how many pages around page selected */
|
$range = 2; /* how many pages around page selected */
|
||||||
|
|
||||||
$n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
|
$n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
|
||||||
$p = Tools::getValue('p', 1);
|
$p = $this->page;
|
||||||
|
|
||||||
if ($p < 0)
|
if ($p < 0)
|
||||||
$p = 0;
|
$p = 0;
|
||||||
|
|||||||
@@ -103,8 +103,13 @@ param_product_url = '#{$param_product_url}';
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{literal}
|
{literal}
|
||||||
|
var filterRange = {/literal}{$filter.max}-{$filter.min}{literal};
|
||||||
|
var step = filterRange / 100;
|
||||||
|
if (step > 1)
|
||||||
|
step = parseInt(step);
|
||||||
addSlider('{/literal}{$filter.type}{literal}',{
|
addSlider('{/literal}{$filter.type}{literal}',{
|
||||||
range: true,
|
range: true,
|
||||||
|
step: step,
|
||||||
min: {/literal}{$filter.min}{literal},
|
min: {/literal}{$filter.min}{literal},
|
||||||
max: {/literal}{$filter.max}{literal},
|
max: {/literal}{$filter.max}{literal},
|
||||||
values: [ {/literal}{$filter.values[0]}{literal}, {/literal}{$filter.values[1]}{literal}],
|
values: [ {/literal}{$filter.values[0]}{literal}, {/literal}{$filter.values[1]}{literal}],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module>
|
<module>
|
||||||
<name>blocklayered</name>
|
<name>blocklayered</name>
|
||||||
<displayName><![CDATA[Layered navigation block]]></displayName>
|
<displayName><![CDATA[Layered navigation block]]></displayName>
|
||||||
<version><![CDATA[1.5]]></version>
|
<version><![CDATA[1.6]]></version>
|
||||||
<description><![CDATA[Displays a block with layered navigation filters.]]></description>
|
<description><![CDATA[Displays a block with layered navigation filters.]]></description>
|
||||||
<author><![CDATA[PrestaShop]]></author>
|
<author><![CDATA[PrestaShop]]></author>
|
||||||
<tab><![CDATA[front_office_features]]></tab>
|
<tab><![CDATA[front_office_features]]></tab>
|
||||||
|
|||||||
Reference in New Issue
Block a user