Skip to content
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-4287 - Add validation for some pages #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AleksandrsKondratjevs
Copy link
Member

Related issue(s):

Problem:

  • Some pages that always present return 404 code.

In this PR:

  • Add validation for pages

@@ -26,6 +26,10 @@
<item name="wishlist" xsi:type="string">ScandiPWA\Router\Validator\Wishlist</item>
<item name="checkout" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="compare" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="customer" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="sales" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="search" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to always pass search? what if there's no results?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, also though about it. But since when no items found in search it actually shows not 404 I decided to stay as 200. It just says no products found.
Also just checked on magento demo and seems same results on how magento acts.
https://magento2-demo.magebit.com/catalogsearch/result/?q=testest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it will be better to add this change, for consistency.
I'm not sure what is the desired behavior, though.

Earlier PWA would return 404 on PLP's on no products, and 200 if there were products.
Search behaves the same way now:
https://luma-demo.scandipwa.com/search/yoloqwe <--- 404
https://luma-demo.scandipwa.com/search/yoloqwe <-- 200

However, it looks like at some point it was changed, and now PLP's always return 200.
Then we may as well do the same for search.
However, if we do that (and it is a desired result), IMO would need to remove the 200/404 status check logic that relates to product count, as that's extra logic that wouldn't be used.

Overall -> I'd consult SEO team, what they want there, 200 or 404, and go with that on both PLP and search.

$path = trim($request->getPathInfo(), '/');
$params = explode('/', $path);

if (count($params) === 1 && $params[0] === self::WISLIST_URL_KEY) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not recommending to fix the param count to 1
some 3rd party extension or project customization could easily transform it to /wishlist/...whatever.
it may be safer to only check if the 0th element is WISLIST_URL_KEY

Copy link

@aleksandrsm aleksandrsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

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

Successfully merging this pull request may close these issues.

ScandiPWA returning 404 status code on page with search results
2 participants