GET error Error when product goes out of stock
We have set up our Magento config so that out-of-stock products are not visible on the website.
If we go to a URL of a product that has become out of stock instead of getting a 404 error we get "Cannot GET /product-url-here'.
The console log shows
GET https://site/product-url 404 (Not Found)
How can we display the 404 page here?
Any help appreciated.2 Replies
It looks like the issue is VSF still gets through the route data based on the product url. This returns the sku/type.
Because of this, it tries to render the Product page, but this throws an error.
I think this is due to not being able to retrieve the product data correctly due to it not being active in Magento.
In the product template it actually checks this product data and if we have no sku throws an error.
This didn't stop the rest of the fetch functions from trying to run though, which caused my issue (was a 500 error).
I've added a return and this is working ok now.
It still loads the product page based on the route response, but now doesn't try to run all the fetch functions and renders the 404 template correctly.
Hi π , I'm glad you got it worked out. Thanks for sharing. π