// Blocklayered: Fix bugs with blocklayered

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14781 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte committed 2012-04-20 08:05:58 +00:00
1 parent d50d727e9c
commit 19956fa86c
2 files changed
+44 -48

No files matched your search

+43 -47
View File
@@ -39,7 +39,7 @@ class BlockLayered extends Module
{ {
$this->name = 'blocklayered'; $this->name = 'blocklayered';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
$this->version = '1.8.3'; $this->version = '1.8.4';
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
$this->need_instance = 0; $this->need_instance = 0;
@@ -258,7 +258,7 @@ class BlockLayered extends Module
INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute) INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group
'.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).' '.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).'
GROUP BY a.id_attribute, pa.id_product, product_attribute_shop.`id_shop`'); GROUP BY a.id_attribute, pa.id_product '.(version_compare(_PS_VERSION_,'1.5','>') ? ', product_attribute_shop.`id_shop`' : ''));
return 1; return 1;
} }
@@ -924,32 +924,28 @@ class BlockLayered extends Module
if ($full) if ($full)
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$nb_products = (int)Db::getInstance()->getValue(' $nb_products = (int)Db::getInstance()->getValue('
SELECT count(*) SELECT count(DISTINCT p.`id_product`)
FROM '._DB_PREFIX_.'product p FROM '._DB_PREFIX_.'product p
INNER JOIN `'._DB_PREFIX_.'product_shop` ps INNER JOIN `'._DB_PREFIX_.'product_shop` ps
ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1)');
GROUP BY p.`id_product`');
else else
$nb_products = (int)Db::getInstance()->getValue(' $nb_products = (int)Db::getInstance()->getValue('
SELECT count(*) SELECT count(DISTINCT p.`id_product`)
FROM '._DB_PREFIX_.'product p FROM '._DB_PREFIX_.'product p
WHERE `active` = 1 WHERE `active` = 1');
GROUP BY p.`id_product`');
else else
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$nb_products = (int)Db::getInstance()->getValue(' $nb_products = (int)Db::getInstance()->getValue('
SELECT COUNT(*) FROM `'._DB_PREFIX_.'product` p SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p
INNER JOIN `'._DB_PREFIX_.'product_shop` ps INNER JOIN `'._DB_PREFIX_.'product_shop` ps
ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1)
LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product)
WHERE psi.id_product IS NULL WHERE psi.id_product IS NULL');
GROUP BY p.`id_product`');
else else
$nb_products = (int)Db::getInstance()->getValue(' $nb_products = (int)Db::getInstance()->getValue('
SELECT COUNT(*) FROM `'._DB_PREFIX_.'product` p SELECT COUNT(DISTINCT p.`id_product`) FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product)
WHERE `active` = 1 AND psi.id_product IS NULL WHERE `active` = 1 AND psi.id_product IS NULL');
GROUP BY p.`id_product`');
$max_executiontime = @ini_get('max_execution_time'); $max_executiontime = @ini_get('max_execution_time');
if ($max_executiontime > 5 || $max_executiontime <= 0) if ($max_executiontime > 5 || $max_executiontime <= 0)
@@ -1017,17 +1013,17 @@ class BlockLayered extends Module
$query = ' $query = '
SELECT p.`id_product` SELECT p.`id_product`
FROM `'._DB_PREFIX_.'product` p FROM `'._DB_PREFIX_.'product` p
WHERE `active` = 1 WHERE `active` = 1
GROUP BY p.`id_product` GROUP BY p.`id_product`
ORDER BY p.`id_product` LIMIT '.(int)$cursor.','.(int)$length; ORDER BY p.`id_product` LIMIT '.(int)$cursor.','.(int)$length;
else else
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$query = ' $query = '
SELECT p.`id_product` SELECT p.`id_product`
FROM `'._DB_PREFIX_.'product` p FROM `'._DB_PREFIX_.'product` p
INNER JOIN `'._DB_PREFIX_.'product_shop` ps INNER JOIN `'._DB_PREFIX_.'product_shop` ps
ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1) ON (ps.`id_product` = p.`id_product` AND ps.`active` = 1)
LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product)
WHERE psi.id_product IS NULL WHERE psi.id_product IS NULL
GROUP BY p.`id_product` GROUP BY p.`id_product`
ORDER BY p.`id_product` LIMIT 0,'.(int)$length; ORDER BY p.`id_product` LIMIT 0,'.(int)$length;
@@ -1804,18 +1800,18 @@ class BlockLayered extends Module
$shops = Shop::getShops(true, null, true); $shops = Shop::getShops(true, null, true);
if (count($shops) > 1) if (count($shops) > 1)
{ {
$helper = new HelperForm(); $helper = new HelperForm();
$helper->id = null; $helper->id = null;
$helper->table = 'layered_filter'; $helper->table = 'layered_filter';
$helper->identifier = 'id_layered_filter'; $helper->identifier = 'id_layered_filter';
if (Shop::isFeatureActive()) if (Shop::isFeatureActive())
{ {
$html .= '<span style="color: #585A69;display: block;float: left;font-weight: bold;text-align: right;width: 200px;" >'.$this->l('Choose shop association:').'</span>'; $html .= '<span style="color: #585A69;display: block;float: left;font-weight: bold;text-align: right;width: 200px;" >'.$this->l('Choose shop association:').'</span>';
$html .= '<div id="shop_association" style="width: 300px;margin-left: 215px;">'.$helper->renderAssoShop().'</div>'; $html .= '<div id="shop_association" style="width: 300px;margin-left: 215px;">'.$helper->renderAssoShop().'</div>';
}
} }
} }
}
$html .= ' $html .= '
<div id="error-treeview" class="error" style="display: none;"> <div id="error-treeview" class="error" style="display: none;">
@@ -2595,7 +2591,7 @@ class BlockLayered extends Module
$sql_query['where'] = 'WHERE product_shop.`active` = 1 '; $sql_query['where'] = 'WHERE product_shop.`active` = 1 ';
} }
else else
$sql_query['where'] = 'WHERE p.`active` = 1 '; $sql_query['where'] = 'WHERE p.`active` = 1 ';
$sql_query['group'] = ' GROUP BY p.id_product '; $sql_query['group'] = ' GROUP BY p.id_product ';
break; break;
@@ -3427,7 +3423,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>')) if (version_compare(_PS_VERSION_,'1.5','>'))
$query_filters = ' AND product_shop.condition IN ('; $query_filters = ' AND product_shop.condition IN (';
else else
$query_filters = ' AND p.condition IN ('; $query_filters = ' AND p.condition IN (';
foreach ($filter_value as $cond) foreach ($filter_value as $cond)
$query_filters .= '\''.$cond.'\','; $query_filters .= '\''.$cond.'\',';
$query_filters = rtrim($query_filters, ',').') '; $query_filters = rtrim($query_filters, ',').') ';
@@ -3775,28 +3771,28 @@ class BlockLayered extends Module
$shops = Shop::getShops(true, null, true); $shops = Shop::getShops(true, null, true);
if (count($shops) > 1) if (count($shops) > 1)
{ {
$helper = new HelperForm(); $helper = new HelperForm();
$helper->id = (int)$id_layered_filter; $helper->id = (int)$id_layered_filter;
$helper->table = 'layered_filter'; $helper->table = 'layered_filter';
$helper->identifier = 'id_layered_filter'; $helper->identifier = 'id_layered_filter';
$helper->base_folder = Tools::getValue('base_folder').'/themes/default/template/helpers/form/'; $helper->base_folder = Tools::getValue('base_folder').'/themes/default/template/helpers/form/';
$html .= ' $html .= '
<div id="shop_association_ajax">'.$helper->renderAssoShop().'</div> <div id="shop_association_ajax">'.$helper->renderAssoShop().'</div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$(\'#shop_association\').html($(\'#shop_association_ajax\').html()); $(\'#shop_association\').html($(\'#shop_association_ajax\').html());
$(\'#shop_association_ajax\').remove(); $(\'#shop_association_ajax\').remove();
// Initialize checkbox // Initialize checkbox
$(\'.input_shop\').each(function(k, v) { $(\'.input_shop\').each(function(k, v) {
check_shop_group_status($(v).val()); check_shop_group_status($(v).val());
check_all_shop(); check_all_shop();
});
}); });
}); </script>';
</script>'; }
} }
} }
}
return $html; return $html;
} }
+1 -1
View File
@@ -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.8.3]]></version> <version><![CDATA[1.8.4]]></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>