-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 36563: Remember Category Pagination causes a Document Expired/form submission error #36595
base: 2.4-develop
Are you sure you want to change the base?
Conversation
…orm submission error
Hi @rogerdz. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Hello @rogerdz ! It is nice to see that you are willing to help out with this issue. I took a look at your current implementation and it is partially working. From what i can see, it does indeed resolve the bug, but it alters the core functionality and basically disregarding the "Remember Category pagination" configuration option by adding the "product_list_limit" parameter to the URL. I wouldn't recommend this approach, especially since it can have an impact on other areas (SEO for example) as well. Fortunately we do have an option that would address this. Lets digg a little deeper into what is actually happing:
In such scenarios, a common practice is to apply a POST/REDIRECT/GET pattern. Nothing fancy about it - we just need to redirect to the same page after the POST action has been processed. We can controll this behaviour from the Magento controller that is responsible for triggering the toolbar parameter saving - namely: Let me know if you are willing to give this another go and refactor the solution a little bit. Thank you for your time! |
…xpired/form submission error" This reverts commit bf30926.
…orm submission error
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Hi @aplapana , |
@rogerdz i left some comments for you. Let me know if you have questions. |
Hi @aplapana, |
@rogerdz are you sure you pushed the changes ? I am not seeing any new commits... |
@aplapana , I changed a day ago and in PR it show my new changed. |
input.name = 'redirect_url'; | ||
input.value = this.options.url; | ||
form.appendChild(input); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't actually need to create an input to pass the current URL to your request. You can do this with PHP, directly in app/code/Magento/Catalog/Controller/Category/View.php controller. Example:
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
.
You can set the respose redirect before the return $page;
statement. Note that the above should be executed under certain conditions:
- memorizing is allowed (see app/code/Magento/Catalog/Model/Product/ProductList/ToolbarMemorizer.php)
- toolbar specific parameters reside in the request. The parameter names are available here:
app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php
(notice the declared constants)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for your review. I added some change in new commit.
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't actually need this. I think a private method that would determine if you need to redirect or not (returns boolean) would be more suitable. Please also specify the method return type.
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@@ -210,6 +209,9 @@ public function execute() | |||
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl()); | |||
} | |||
$category = $this->_initCategory(); | |||
if ($this->toolbarMemorizer->hasMemorizingParam()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also check if memorizing is allowed via $this->toolbarMemorizer->isMemorizingAllowed() method call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary. $this->hasMemorizeParam is always false, only true when new category parameter is saved to the session (this only happens when memorizing is allowed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it is necessary. You can implement the change and have the tests run again and see how it goes. We can always revert the change. Please bare in mind that in order for this to pass, all tests need to pass.
Also, once we have a stable solution, we will need to have testing coverage for the new code.
Description (*)
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)