Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Page mode not remembered correctly when using ajax filtering #17

Open
5 tasks
TomFranssen opened this issue Jun 22, 2018 · 4 comments
Open
5 tasks

Page mode not remembered correctly when using ajax filtering #17

TomFranssen opened this issue Jun 22, 2018 · 4 comments

Comments

@TomFranssen
Copy link

TomFranssen commented Jun 22, 2018

Issue Brief

On product list pages with ajax filtering enabled, the page mode (grid and list) is not always remembered correctly.

Environment

  • Tweakwise Version: 1.11.5
  • Magento Version: 1.9.3.8
  • Magento Enterprise: no
  • Tweakwise Layered Navigation and Ajax loading enabled

Steps to reproduce

  1. Navigate to a product list page
  2. Switch the product page mode (by clicking on the grid or list icon)
  3. Switch the product page mode again (by clicking on the grid or list icon)
  4. Switch the product page mode for the third time (by clicking on the grid or list icon)
  5. Click on a filter link, pagination link or change the sort criteria

Actual result

  1. You now see that the page mode is put back to the mode from step 1

Expected result

  • The page mode from step 4 should be remembered
@edwinljacobs
Copy link
Contributor

Hello,

Thanks for reporting, I am not sure what you mean by switching to page mode, to clarify, do you mean that the p parameter is not correct when switching between pages of a category product list view? Namely when on page 1 then go to page 3 and the pager urls are incorrect?

If this is the case then I noticed this as well and have a fix for it, we will problably roll this out in this week. If not what do you mean by "switch the product page mode"?

With kind regards

@TomFranssen
Copy link
Author

TomFranssen commented Jun 25, 2018

With switching the page mode I mean switching from grid to list or vice versa, I added this in the ticket to clarify.

@pimdebrabander
Copy link

pimdebrabander commented Jul 4, 2018

The problem here is that the history cache key does not include the state of the page (page mode, selected sorting, sort order, and sometimes also the page (page 1 for example)). So currently when requesting a page which is already in the cache, it will show the state of the page when it was saved to the cache and not necessarily the current state. So if the page was cached in grid view, it will always show the grid view when requesting that page again. So what i think needs to be done is adding the state to the history cache key.

Another problem that will arise when the history cache key is updated with the current state, is that the state in the Magento session is not updated. For example when page 4 is in the cache with 2 different states, one being page mode grid and the other being page mode list. When switching between these pages, no Ajax call will be done (which is logical because they are cached). But the problem here is that when going to page 5, the Magento session contains the display mode of the last Ajax request and uses this display mode to render page 5. So it could happen that you are on page 4 with the grid view, and then end up with the list view on page 5. To fix this i think the Ajax request should always provide the current state (as query paramater) as well which results in updating the session with the correct mode.

So basically the state should be managed in Javascript and passed to Magento in each request (and also in the cache key). However, this makes the caching of the request a little complicated and may introduce other bugs in the future. Another option here would be to remove the caching entirely and always execute the request.

@pimdebrabander
Copy link

pimdebrabander commented Jul 17, 2018

Hello,

We noticed that this issue only occurs when extending the linkSelector parameter in the filter_ajax.js (with for instance the page mode selector), and that by default page mode switching and page selection with ajax does not seem to be supported in the module. So basically this is not a bug but a feature request. Sorry for the misunderstanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants