How do I return a 404 page for pages beyond category pagination pages?
-
01-10-2020 - |
Question
That title sounds confusing, sorry.
But basically I have a category grid page, with pagination.
So I have pages like:
/men/tops/shirts.html
/men/tops/shirts.html?p=2
/men/tops/shirts.html?p=3
This is all fine and good, but if I do this:
/men/tops/shirts.html?p=987654
That URL will load the last available page of products. How do I instead make this return a 404 error?
Basically I need to do this for Infinite Scroll's sake. Otherwise my infinite scroll keeps loading the last page of products and never ends.
Solution
If you are using a custom controller, you can add
$this->_forward('noRoute')
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange