Seekme Posted January 6, 2015 Share Posted January 6, 2015 Bonjour,Je suis tombé sur quelque chose qui me semble bizarre, en modifiant le module de navigation à facette, dans blocklayered.js : function reloadContent(params_plus) { stopAjaxQuery(); if (!ajaxLoaderOn) { $('.product_list').prepend($('#layered_ajax_loader').html()); $('.product_list').css('opacity', '0.7'); ajaxLoaderOn = 1; } data = $('#layered_form').serialize(); $('.layered_slider').each( function () { var sliderStart = $(this).slider('values', 0); var sliderStop = $(this).slider('values', 1); if (typeof(sliderStart) == 'number' && typeof(sliderStop) == 'number') data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop; }); $(['price', 'weight']).each(function(it, sliderType) { if ($('#layered_'+sliderType+'_range_min').length) { data += '&layered_'+sliderType+'_slider='+$('#layered_'+sliderType+'_range_min').val()+'_'+$('#layered_'+sliderType+'_range_max').val(); } }); $('#layered_form .select option').each( function () { if($(this).attr('id') && $(this).parent().val() == $(this).val()) { data += '&'+$(this).attr('id') + '=' + $(this).val(); } }); if ($('.selectProductSort').length && $('.selectProductSort').val()) { if ($('.selectProductSort').val().search(/orderby=/) > 0) { // Old ordering working var splitData = [ $('.selectProductSort').val().match(/orderby=(\w*)/)[1], $('.selectProductSort').val().match(/orderway=(\w*)/)[1] ]; } else { // New working for default theme 1.4 and theme 1.5 var splitData = $('.selectProductSort').val().split(':'); } data += '&orderby='+splitData[0]+'&orderway='+splitData[1]; } if ($('select[name=n]:first').length) { if (params_plus) data += '&n=' + $('select[name=n]:first').val(); else data += '&n=' + $('div.pagination form.showall').find('input[name=n]').val(); } var slideUp = true; if (params_plus == undefined) { params_plus = ''; slideUp = false; } // Get nb items per page var n = ''; if (params_plus) { $('div.pagination select[name=n]').children().each(function(it, option) { if (option.selected) n = '&n=' + option.value; }); } ajaxQuery = $.ajax( { type: 'GET', url: baseDir + 'modules/blocklayered/blocklayered-ajax.php', data: data+params_plus+n, dataType: 'json', cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example success: function(result) { if (result.meta_description != '') $('meta[name="description"]').attr('content', result.meta_description); if (result.meta_keywords != '') $('meta[name="keywords"]').attr('content', result.meta_keywords); if (result.meta_title != '') $('title').html(result.meta_title); if (result.heading != '') $('h1.page-heading .cat-name').html(result.heading); $('#layered_block_left').replaceWith(utf8_decode(result.filtersBlock)); $('.category-product-count, .heading-counter').html(result.categoryCount); if (result.nbRenderedProducts == result.nbAskedProducts) $('div.clearfix.selector1').hide(); if (result.productList) $('.product_list').replaceWith(utf8_decode(result.productList)); else $('.product_list').html(''); $('.product_list').css('opacity', '1'); if ($.browser.msie) // Fix bug with IE8 and aliasing $('.product_list').css('filter', ''); if (result.pagination.search(/[^\s]/) >= 0) { var pagination = $('<div/>').html(result.pagination) var pagination_bottom = $('<div/>').html(result.pagination_bottom); if ($('<div/>').html(pagination).find('#pagination').length) { $('#pagination').show(); $('#pagination').replaceWith(pagination.find('#pagination')); } else { $('#pagination').hide(); } if ($('<div/>').html(pagination_bottom).find('#pagination_bottom').length) { $('#pagination_bottom').show(); $('#pagination_bottom').replaceWith(pagination_bottom.find('#pagination_bottom')); } else { $('#pagination_bottom').hide(); } } else { $('#pagination').hide(); $('#pagination_bottom').hide(); } paginationButton(result.nbRenderedProducts, result.nbAskedProducts); ajaxLoaderOn = 0; // On submiting nb items form, relaod with the good nb of items $('div.pagination form').on('submit', function(e) { e.preventDefault(); val = $('div.pagination select[name=n]').val(); $('div.pagination select[name=n]').children().each(function(it, option) { if (option.value == val) $(option).attr('selected', true); else $(option).removeAttr('selected'); }); // Reload products and pagination reloadContent(); }); if (typeof(ajaxCart) != "undefined") ajaxCart.overrideButtonsInThePage(); if (typeof(reloadProductComparison) == 'function') reloadProductComparison(); filters = result.filters; initFilters(); initSliders(); current_friendly_url = result.current_friendly_url; // Currente page url if (typeof(current_friendly_url) === 'undefined') current_friendly_url = '#'; // Get all sliders value $(['price', 'weight']).each(function(it, sliderType) { if ($('#layered_'+sliderType+'_slider').length) { // Check if slider is enable & if slider is used if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object') { if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min') || $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max')) current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1) } } else if ($('#layered_'+sliderType+'_range_min').length) { current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val(); } }); if (current_friendly_url == '#') current_friendly_url = '#/'; window.location.href = current_friendly_url; if (current_friendly_url != '#/show-all') $('div.clearfix.selector1').show(); lockLocationChecking = true; if(slideUp) $.scrollTo('.product_list', 400); updateProductUrl(); $('.hide-action').each(function() { hideFilterValueAction(this); }); if (display instanceof Function) { var view = $.totalStorage('display'); if (view && view != 'grid') display(view); } } }); ajaxQueries.push(ajaxQuery); } Désolé pour le gros paté, au moment de l'appel en ajax, on envoi data: data+params_plus+n Le param_plus semble être gênant, il rajoute true aux paramètres et particulièrement au tri qui envoi donc quelque chose comme &orderby=name&orderway=asctrue.Par défaut la valeur est ASC donc si on envoi un tri décroissant (desctrue) c'est la valeur par défaut qui est prise et donc pas de tri décroissant.J'ai installé une version "propre" de prestashop et le soucis est identique, je ne peux pas trier de façon décroissante.Qu'en pensez vous ? Est-ce vraiment un bug que je dois rapporter ? Est-ce seulement chez moi ?PS : version 1.6.0.9 de Presta et 2.0.5 du module navigation à facettes Link to comment Share on other sites More sharing options...
Seekme Posted January 6, 2015 Author Share Posted January 6, 2015 Je viens de trouver un sujet similaire avec la solution : http://www.prestashop.com/forums/topic/368130-sort-by-problem/Faudrait-il envoyer une requête Git ici https://github.com/PrestaShop/blocklayered ? Link to comment Share on other sites More sharing options...
SOURIRE DES SAVEURS Posted August 1, 2015 Share Posted August 1, 2015 si le système de cache, peu importe lequel, est activé dans paramètres avancés / performances, la navigation à facette ne fonctionne pas et mélange tous les produits de votre site. Je n'ai pour l'instant pas trouvé la solution, pourtant j'aimerai, pour les performances de mon site, activer le cache. Je vous remercie de m'informer quand ce sera possible ou si vous avez la solution. Link to comment Share on other sites More sharing options...
Akey Posted October 31, 2017 Share Posted October 31, 2017 (edited) Hello, J'avais toujours le même problème que vous en 2017... Le correctif n'est toujours pas fait. le problème vient de la variable params_plus qui lors du chargement de la page récupère les informations de filtrage mais par la suite lorsque l'on veut faire un tri par prix décroissant par exemple contient "forceSlide". Ce qui rend la requête ajax corrompue : data = id_category_layered=3&orderby=price&orderway=desc param_plus = forceSlide n = [RIEN DU TOUT] data+param_plus+n = id_category_layered=3&orderby=price&orderway=descforceSlide Pour fixer le problème facilement et simplement. Ajouter cela juste devant la requête ajax. if (params_plus === 'forceSlide') params_plus = ''; Comme dans l'exemple ci dessous : // Get nb items per page var n = ''; if (params_plus) { $('div.pagination select[name=n]').children().each(function(it, option) { if (option.selected) { n = '&n=' + option.value; } }); } /* PROBLEM SOLVED */ if (params_plus === 'forceSlide') params_plus = ''; /* END PROBLEM SOLVED */ ajaxQuery = $.ajax( { type: 'GET', url: baseDir + 'modules/blocklayered/blocklayered-ajax.php', data: data+params_plus+n, dataType: 'json', cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example success: function(result) { Edited October 31, 2017 by Akey informations détaillées sur le problème de requête (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now