Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jan 2015
    Location
    Us
    Posts
    8
    Plugin Contributions
    0

    Default Problem about control the 404 error product

    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:
    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'] < 1 ) {
       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

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

    Default Re: Problem about control the 404 error product

    To ensure that you identify all of the locations that apply as other plugins may also filter disabled product out, go to your admin panel, tools, developers toolkit.
    In the lower left corner enter: products_status
    Select catalog in the dropdown, then search...

    This will provide the list of files that and the line number of the code where that is used... From there you may need to make modifications to the code to obtain the desired result. Remember that if a returned file has the ability to be overridden with a template equivalent to copy the base file if it doesn't exist in the associated template folder and make the change there. The pages directory identified above is not overrideable, so yes the above modification should support product_info (product-general) products being displayed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Problem about control the 404 error product

    Yes, you can actually remove (or comment out) that whole section of code you quoted.

    And, in the first 60 lines of main_template_vars.php in that same folder, remove the 2 criteria for products_status in those queries too.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: Problem about control the 404 error product

    And similar process for the other product types (default install has 5 product types to start with other plugins possibly creating additional) if you are using any of them ... (Ie. Document-general, etc...)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 What files control the 404 product not found?
    By philip937 in forum General Questions
    Replies: 13
    Last Post: 12 Oct 2014, 03:52 PM
  2. Replies: 3
    Last Post: 20 Sep 2014, 07:15 PM
  3. v151 problem about product display of the subcategory?
    By fanisme in forum General Questions
    Replies: 7
    Last Post: 3 May 2013, 07:48 AM
  4. The problem about the link product
    By huaxu22 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 6 Aug 2009, 08:43 AM
  5. Problem in adding new Product - error 404
    By alhakeem2001 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 27 Mar 2008, 07:37 AM

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