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

Provide the option of not going to 404 when product status is 0 #2551

Merged
merged 1 commit into from Jul 16, 2019

Conversation

drbyte
Copy link
Member

@drbyte drbyte commented Jul 12, 2019

Split out the code for handling 404 Header responses so it can be intercepted with an Observer if needed.
Added ability to define a constant PRODUCT_THROWS_200_WHEN_DISABLED to boolean true without needing an Observer, if a Store wishes to allow a product to display even when disabled.
A 404 will still trigger if the product doesn't actually exist in the db.
A 410 can be triggered by setting products_status to -1 in custom code, without needing an observer for the 410 response.

This change should also reduce queries on product page.

Fixes #1699

@drbyte
Copy link
Member Author

drbyte commented Jul 12, 2019

Testing/feedback welcome

@scottcwilson
Copy link
Sponsor Contributor

@drbyte do you want me to put PRODUCT_THROWS_200_WHEN_DISABLED in the database?

@drbyte
Copy link
Member Author

drbyte commented Jul 12, 2019

@drbyte do you want me to put PRODUCT_THROWS_200_WHEN_DISABLED in the database?

No, I wasn't planning on adding more config entries. The related discussion talked about this somewhat.

@drbyte drbyte requested review from zcwilt and ajeh July 13, 2019 15:02
@scottcwilson
Copy link
Sponsor Contributor

Wondering if we should change the 404 to a 410 still. I am not strong on this - just wondering.

@drbyte
Copy link
Member Author

drbyte commented Jul 13, 2019

In this PR the 404 is triggered if "product does not exist in database".
This situation would happen for basically 2 cases:

  1. product never existed. This is likely only to occur with bots or uncouth visitors. 404 is ideal.
  2. product "did" exist, but has been actually deleted. A hit of this sort is likely from search engines or bookmarks or old newsletters. A 410 would be ideal.

Thinking about it, I guess the latter is more likely to occur.

Split out the code for handling 404 Header responses so it can be intercepted with an Observer if needed.
Added ability to define a constant PRODUCT_THROWS_200_WHEN_DISABLED to boolean `true` without needing an Observer, if a Store wishes to allow a product to display even when disabled.
A 404 will still trigger if the product doesn't actually exist in the db.
A 410 can be triggered by setting `products_status` to `-1` in custom code, without needing an observer for the 410 response.

This change should also reduce queries on product page.

Fixes zencart#1699
@drbyte drbyte force-pushed the product-status-404-override branch from 4268f28 to 46ae2ee Compare July 14, 2019 18:01
@drbyte drbyte merged commit ebc2bb4 into zencart:v157 Jul 16, 2019
@drbyte drbyte deleted the product-status-404-override branch July 16, 2019 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide the option of not going to 404 when product status is 0
3 participants