Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default What files control the 404 product not found?

    Hi all, I touched on this quite some time ago but can't seem to find the thread.

    I want to change the behaviour of my site when products are disabled. Instead of displaying the product not found page and issuing a 404 message, I want the product to display as normal.

    So essentially, all I want disabling a product to do is for it to not be listed in the front facing catalogue and thus ensuring that the original link tot the item (whilst the id exists) still works. meaning that if someone shared a link somewhere to an old product, I still want that link to work and display the product.

    so as a start, in the following file:

    includes/modules/pages/product_info/header_php.php

    this code:
    PHP Code:
     // if specified product_id is disabled or doesn't exist, ensure that metatags and breadcrumbs don't share inappropriate information
      
    $sql "select count(*) as total
              from " 
    TABLE_PRODUCTS " p, " .
                       
    TABLE_PRODUCTS_DESCRIPTION " pd
              where    p.products_status = '1'
              and      p.products_id = '" 
    . (int)$_GET['products_id'] . "'
              and      pd.products_id = p.products_id
              and      pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'";
      
    $res $db->Execute($sql);
      if ( 
    $res->fields['total'] < ) {
       unset(
    $_GET['products_id']);
        unset(
    $breadcrumb->_trail[sizeof($breadcrumb->_trail)-1]['title']);
        
    $robotsNoIndex true;
        
    header('HTTP/1.1 404 Not Found');
      } 
    I assume I just remove the p.products_status = '1' WHERE clause and that will remove the 404 bit?

    Thats just the start, can someone point me to ALL the other places I need to make a similar change so that the page displays correctly even when the product is disabled?

    Many Thanks

    Phil
    Phil Rogers
    A problem shared is a problem solved.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: What files control the 404 product not found?

    Quote Originally Posted by philip937 View Post
    Hi all, I touched on this quite some time ago but can't seem to find the thread.

    I want to change the behaviour of my site when products are disabled. Instead of displaying the product not found page and issuing a 404 message, I want the product to display as normal.

    So essentially, all I want disabling a product to do is for it to not be listed in the front facing catalogue and thus ensuring that the original link tot the item (whilst the id exists) still works. meaning that if someone shared a link somewhere to an old product, I still want that link to work and display the product.

    so as a start, in the following file:

    includes/modules/pages/product_info/header_php.php

    this code:
    PHP Code:
     // if specified product_id is disabled or doesn't exist, ensure that metatags and breadcrumbs don't share inappropriate information
      
    $sql "select count(*) as total
              from " 
    TABLE_PRODUCTS " p, " .
                       
    TABLE_PRODUCTS_DESCRIPTION " pd
              where    p.products_status = '1'
              and      p.products_id = '" 
    . (int)$_GET['products_id'] . "'
              and      pd.products_id = p.products_id
              and      pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'";
      
    $res $db->Execute($sql);
      if ( 
    $res->fields['total'] < ) {
       unset(
    $_GET['products_id']);
        unset(
    $breadcrumb->_trail[sizeof($breadcrumb->_trail)-1]['title']);
        
    $robotsNoIndex true;
        
    header('HTTP/1.1 404 Not Found');
      } 
    I assume I just remove the p.products_status = '1' WHERE clause and that will remove the 404 bit?

    Thats just the start, can someone point me to ALL the other places I need to make a similar change so that the page displays correctly even when the product is disabled?

    Many Thanks

    Phil
    Maybe it's just "luck" that this one snippet of code was used, but looks like the intent is to try to game the system about what is offered on the site.

    Have you ever shopped at a site where it is impossible to find the thing that got you to the site other than from some external site? If the real intent is to target customers, I hope when that product is disabled that there is some good information about the situation as it sounds like once on the site at that product that can't be purchased because it no longer exists, it can never be found on the store again either as it won't display in the category(ies) in which it assigned.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: What files control the 404 product not found?

    My question was about zen cart code. I am not sure I understand your response?
    Phil Rogers
    A problem shared is a problem solved.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: What files control the 404 product not found?

    Quote Originally Posted by philip937 View Post
    My question was about zen cart code. I am not sure I understand your response?
    Sorry, the short of it is: Why? Please explain.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: What files control the 404 product not found?

    Why what? Why do I want my URL to display useful information? Because someone landing on a white 404 page (or even a generic custom 404 page) is not helpful and a potential customer will bounce 99.99% of the time.

    So the reasoning is that the user will land on a page where yes the product is no longer avaiable but will have custom code referring customers to newer and existing alternatives.

    So the link remains useful.
    Phil Rogers
    A problem shared is a problem solved.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: What files control the 404 product not found?

    Quote Originally Posted by philip937 View Post
    Why what? Why do I want my URL to display useful information? Because someone landing on a white 404 page (or even a generic custom 404 page) is not helpful and a potential customer will bounce 99.99% of the time.

    So the reasoning is that the user will land on a page where yes the product is no longer avaiable but will have custom code referring customers to newer and existing alternatives.

    So the link remains useful.
    Sounds like then still have a custom '404' page, but without telling the internet machines that there is/was a '404' error. Why do that?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: What files control the 404 product not found?

    404 not found. If the page is there then it is found. To be honest the question wasn't asking advice on the logic, I was after the technical answer.
    Phil Rogers
    A problem shared is a problem solved.

  8. #8
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: What files control the 404 product not found?

    Quote Originally Posted by philip937 View Post
    I assume I just remove the p.products_status = '1' WHERE clause and that will remove the 404 bit?
    This assumption isn't quite correct.

    Removing the p.products_status = '1' will include the disabled product in the count(*), and that will indeed cause the '404 bit' to be skipped, assuming the product is still in the DB, but if the product with the $_GET['products_id'] has been deleted the res->fields['total'] will still be < 1 and the '404 bit' will be acted upon.

    This may or may not be what you are after.

    Cheers
    RodG

  9. #9
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: What files control the 404 product not found?

    Quote Originally Posted by philip937 View Post
    404 not found. If the page is there then it is found. To be honest the question wasn't asking advice on the logic, I was after the technical answer.
    My apologies that the thought is that asking a question necessitates an answer without discourse on the reasons and intentions. Heaven forbid that someone try to do something that appears as if involve a lot of work on their side to sustain or that appears to be trying to let search engines believe that the link previously found leads to the same content and really is a valid/useful link instead of a basic redirect without making it known that it is a redirect or any other type of non-existent product.

    The solution is simple, and can be performed/determined from your own store's admin and some form of ftp/file manipulation tool. I'm still not convinced that the solution is one to which I feel it is right to give an answer and will allow another to offer the answer of pointing you to ALL the other places you need to make a similar change so that the page displays correctly even when the product is disabled?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: What files control the 404 product not found?

    Yes that pretty much what I'm after. So a disabled product will:

    - Not be visible in the product listings
    - Accessible via external links

    A product deleted from database will:
    - Will return 404 not found

    In addition to the above I need to find out what code I need to change so that the product info page displays normally with the content and page title etc.

    Any ideas RodD?
    Phil Rogers
    A problem shared is a problem solved.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Problem about control the 404 error product
    By macbookpro in forum General Questions
    Replies: 3
    Last Post: 23 Jan 2015, 09:32 PM
  2. v151 product not found 404
    By lpm92 in forum General Questions
    Replies: 3
    Last Post: 7 Oct 2013, 01:48 PM
  3. Admin 404 Not Found The requested URL was not found on this server
    By L.a.Willman in forum Installing on a Windows Server
    Replies: 23
    Last Post: 10 Jan 2012, 02:26 AM
  4. Add product gives a 404 not found
    By Bastelboy in forum General Questions
    Replies: 1
    Last Post: 2 Jan 2011, 10:04 PM
  5. ZJ Black 2 - What files control the New Tab?
    By Beau91324 in forum Addon Templates
    Replies: 1
    Last Post: 27 Apr 2010, 03:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR