Jump to content

Different 404 message if a product is out of stock (but still unpublished)


cb2004
 Share

Recommended Posts

I have creating a website that reads an XML file to pull in products (pages). When a product is out of stock in the XML file, this page becomes unpublished. I want to display a different 404 message to what is usually seen if a product is unpublished and was just wondering the best way to go about this? Or would the best thing be to set it to hidden, and then check if the page is hidden on the template level and do the logic there?

Cheers.

Link to comment
Share on other sites

Have not tried it so no gurantees.

404 page is just a page (though with it's id or name or both hard coded somewhere in the core). It is accessible in the page tree. So try to change the template of that page and write some code in template file to handle your case. Something has to be availiable there, like the url initially requested.

But honestly I do not think that throwing a 404 for a product out of stock is a good idea in the first place. Maybe show some message (but with the 200 code) and handle the case in the product template file.

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...