Merge branch 'ticket-12827-BugFilterProductList'
This commit is contained in:
commit
2db650855b
@ -71,71 +71,74 @@ if($id_category && $p && $id_category > 1) {
|
||||
// $cat_products = $category->getProducts($cookie->id_lang, $p + 1, $n, $orderBy, $orderWay);
|
||||
}
|
||||
|
||||
$smarty->assign('products', $cat_products);
|
||||
if(!$cat_products) {
|
||||
$smarty->assign('products', array());
|
||||
} else {
|
||||
$smarty->assign('products', $cat_products);
|
||||
$id_products = array();
|
||||
foreach($cat_products as $p) {
|
||||
$id_products[] = $p['id_product'];
|
||||
}
|
||||
$attributes = array();
|
||||
$id_attributes = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT pa.`id_product`, pa.`quantity`, ag.`public_name` as `group`, al.`name`, al.`id_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa, `'._DB_PREFIX_.'product_attribute_combination` ac, `'._DB_PREFIX_.'attribute` a, `'._DB_PREFIX_.'attribute_lang` al, `'._DB_PREFIX_.'attribute_group_lang` ag
|
||||
WHERE pa.`id_product` IN ('.implode(', ', $id_products).')
|
||||
AND ac.`id_product_attribute` = pa.`id_product_attribute`
|
||||
AND al.`id_attribute` = ac.`id_attribute`
|
||||
AND al.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND a.`id_attribute` = al.`id_attribute`
|
||||
AND ag.`id_attribute_group` = a.`id_attribute_group`
|
||||
AND ag.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND pa.`quantity` > 0
|
||||
AND ag.`id_attribute_group` IN(75, 9, 272, 172)
|
||||
ORDER BY pa.`id_product` ASC, ag.`public_name` ASC, al.`name` ASC
|
||||
') as $attr) {
|
||||
if(!isset($attributes[$attr['id_product']])) {
|
||||
$attributes[$attr['id_product']] = array();
|
||||
}
|
||||
if(!isset($attributes[$attr['id_product']][$attr['group']])) {
|
||||
$attributes[$attr['id_product']][$attr['group']] = array();
|
||||
}
|
||||
if(!isset($id_attributes[$attr['id_product']])) {
|
||||
$id_attributes[$attr['id_product']] = array();
|
||||
}
|
||||
|
||||
if(!in_array($attr['id_attribute'], $id_attributes[$attr['id_product']])) {
|
||||
$attributes[$attr['id_product']][$attr['group']][] = array(
|
||||
'name' => $attr['name'],
|
||||
'quantity' => $attr['quantity'],
|
||||
);
|
||||
$id_attributes[$attr['id_product']][] = $attr['id_attribute'];
|
||||
}
|
||||
}
|
||||
|
||||
// $images = array();
|
||||
// foreach ($id_products as $key => $id_product) {
|
||||
// $product = new Product($id_product);
|
||||
// $images_product = $product->getImages((int) $cookie->id_lang);
|
||||
// $images[(int)$id_product] = $images_product;
|
||||
// }
|
||||
$images = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT i.`id_product`, i.`cover`, i.`id_image`, il.`legend`, i.`position`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($cookie->id_lang).')
|
||||
WHERE i.`id_product` IN ('.implode(', ', $id_products).')
|
||||
ORDER BY `position`
|
||||
') as $img) {
|
||||
if(!isset($images[$img['id_product']])) {
|
||||
$images[$img['id_product']] = array();
|
||||
}
|
||||
$images[$img['id_product']][] = $img;
|
||||
}
|
||||
|
||||
$smarty->assign('images', $images);
|
||||
$smarty->assign('categoryProductAttributes', $attributes);
|
||||
|
||||
$id_products = array();
|
||||
foreach($cat_products as $p) {
|
||||
$id_products[] = $p['id_product'];
|
||||
}
|
||||
$attributes = array();
|
||||
$id_attributes = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT pa.`id_product`, pa.`quantity`, ag.`public_name` as `group`, al.`name`, al.`id_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa, `'._DB_PREFIX_.'product_attribute_combination` ac, `'._DB_PREFIX_.'attribute` a, `'._DB_PREFIX_.'attribute_lang` al, `'._DB_PREFIX_.'attribute_group_lang` ag
|
||||
WHERE pa.`id_product` IN ('.implode(', ', $id_products).')
|
||||
AND ac.`id_product_attribute` = pa.`id_product_attribute`
|
||||
AND al.`id_attribute` = ac.`id_attribute`
|
||||
AND al.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND a.`id_attribute` = al.`id_attribute`
|
||||
AND ag.`id_attribute_group` = a.`id_attribute_group`
|
||||
AND ag.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND pa.`quantity` > 0
|
||||
AND ag.`id_attribute_group` IN(75, 9, 272, 172)
|
||||
ORDER BY pa.`id_product` ASC, ag.`public_name` ASC, al.`name` ASC
|
||||
') as $attr) {
|
||||
if(!isset($attributes[$attr['id_product']])) {
|
||||
$attributes[$attr['id_product']] = array();
|
||||
}
|
||||
if(!isset($attributes[$attr['id_product']][$attr['group']])) {
|
||||
$attributes[$attr['id_product']][$attr['group']] = array();
|
||||
}
|
||||
if(!isset($id_attributes[$attr['id_product']])) {
|
||||
$id_attributes[$attr['id_product']] = array();
|
||||
}
|
||||
|
||||
if(!in_array($attr['id_attribute'], $id_attributes[$attr['id_product']])) {
|
||||
$attributes[$attr['id_product']][$attr['group']][] = array(
|
||||
'name' => $attr['name'],
|
||||
'quantity' => $attr['quantity'],
|
||||
);
|
||||
$id_attributes[$attr['id_product']][] = $attr['id_attribute'];
|
||||
}
|
||||
}
|
||||
|
||||
// $images = array();
|
||||
// foreach ($id_products as $key => $id_product) {
|
||||
// $product = new Product($id_product);
|
||||
// $images_product = $product->getImages((int) $cookie->id_lang);
|
||||
// $images[(int)$id_product] = $images_product;
|
||||
// }
|
||||
$images = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT i.`id_product`, i.`cover`, i.`id_image`, il.`legend`, i.`position`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($cookie->id_lang).')
|
||||
WHERE i.`id_product` IN ('.implode(', ', $id_products).')
|
||||
ORDER BY `position`
|
||||
') as $img) {
|
||||
if(!isset($images[$img['id_product']])) {
|
||||
$images[$img['id_product']] = array();
|
||||
}
|
||||
$images[$img['id_product']][] = $img;
|
||||
}
|
||||
|
||||
$smarty->assign('images', $images);
|
||||
$smarty->assign('categoryProductAttributes', $attributes);
|
||||
$smarty->assign('last_qties', (int)Configuration::get('PS_LAST_QTIES'));
|
||||
|
||||
$result['products'] = $smarty->fetch(file_exists(_PS_THEME_DIR_.'modules/categoryscroll/product-list.tpl')? '../../themes/'._THEME_NAME_.'/modules/categoryscroll/product-list.tpl': 'product-list.tpl', __FILE__);
|
||||
}
|
||||
} else {
|
||||
|
@ -25,17 +25,22 @@
|
||||
$('.open').live('click', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
$('.block_filter .content').css({'position':'relative'});
|
||||
var new_top = $('#privatesales_categories_block_left').position().top;
|
||||
if($('#privatesales_categories_block_left').length>0) {
|
||||
$('.block_filter .content').css({'position':'relative'});
|
||||
var new_top = $('#privatesales_categories_block_left').position().top;
|
||||
}
|
||||
|
||||
$(this).toggleClass('active');
|
||||
$('.content_filter').toggle();
|
||||
if($(this).hasClass('active') == true) {
|
||||
new_top = $('#privatesales_categories_block_left').position().top + $('.block_filter .content_filter').height() + 25;
|
||||
} else {
|
||||
new_top = $('.block_filter').position().top + $('.block_filter').height();
|
||||
}
|
||||
$('#privatesales_categories_block_left').css({'top': new_top});
|
||||
|
||||
if($('#privatesales_categories_block_left').length>0) {
|
||||
if($(this).hasClass('active') == true) {
|
||||
new_top = $('#privatesales_categories_block_left').position().top + $('.block_filter .content_filter').height() + 25;
|
||||
} else {
|
||||
new_top = $('.block_filter').position().top + $('.block_filter').height();
|
||||
}
|
||||
$('#privatesales_categories_block_left').css({'top': new_top});
|
||||
}
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
|
@ -64,7 +64,6 @@ $(document).ready(function() {
|
||||
filter.push($(this).val());
|
||||
});
|
||||
$("#product_list").val(0);
|
||||
|
||||
loading = true;
|
||||
$.get("{/literal}{$base_dir_ssl}{literal}modules/categoryscroll/ajax.php?c={/literal}{$id_category}{literal}&init=1&f="+ filter +"&p=1", function(loaded) {
|
||||
loaded = $.parseJSON(loaded)[0];
|
||||
@ -88,6 +87,7 @@ $(document).ready(function() {
|
||||
"privatesale_inactive": "{/literal}{l s='This sale is now disabled.' mod='categoryscroll'}{literal}",
|
||||
"permission_denied": "{/literal}{l s='You can\'t access this content.' mod='categoryscroll'}{literal}",
|
||||
"invalid_request": "{/literal}{l s='Invalid request.' mod='categoryscroll'}{literal}",
|
||||
"product_not_found": "{/literal}{l s='Product not found.' mod='categoryscroll'}{literal}",
|
||||
"inactive_category": "{/literal}{l s='This category is disabled.' mod='categoryscroll'}{literal}"
|
||||
};
|
||||
$('<div class="error">' + error_i18n[loaded.error] + '</div>').insertAfter("#product_list");
|
||||
|
Loading…
Reference in New Issue
Block a user