If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Hide Disabled Products from "All Products sidebar search"

Hide Disabled Products from "All Products sidebar search"

Started by mshultise on 23 May 2014, 7:09 PM · Views: 660

Results 1 to 5 of 5
23 May 2014, 7:09 PM
#1
mshultise avatar

mshultise

Zen Follower

Join Date:
Feb 2005
Location:
Captain Cook, Hawaii
Posts:
172
Plugin Contributions:
0

Hide Disabled Products from "All Products sidebar search"

I want to hide disabled products and disabled categories from the "ALL PRODUCTS", "NEW PRODUCTS" links.

I saw somewhat similar requests on previous versions but have not found a 1.5.1 fix.

For ALL PRODUCTS I believe the correct file is /includes/modules/pages/products_all/header_php.php and that "WHERE p.products_status = 1" might be the magic phrase.

Should the SELECT be modified or the following "needs a better check v1.3.1" section?

If the latter, don't I need to pull the "p.products_status" also in the select?

I have tried a few tests and have not found the right way to do this. Can you paste in the correct code for me?

Aloha from Hawaii! (its a dirty job, but SOMEBODY has to live here...)

23 May 2014, 7:57 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Hide Disabled Products from "All Products sidebar search"

Did you upgrade from a previous Zen Cart version? Looking at the ZC v1.5.1 distribution version of /includes/modules/pages/products_all/header_php.php, the query is already restricted to only those products that are enabled, i.e. products_status = 1:

  $products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
                                    p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
                                    p.product_is_always_free_shipping, p.products_qty_box_status,
                                    p.master_categories_id
                             FROM " . TABLE_PRODUCTS . " p
                             LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
                             WHERE p.products_status = 1
                             AND p.products_id = pd.products_id
                             AND pd.language_id = :languageID " . $order_by;

You might try using a file-comparison tool like WinMerge or Beyond Compare to see what's different between your files and the "stock" v1.5.1 version. The products_new page default header_php.php file also contains the "enabled products only" distinction in its SQL query.

23 May 2014, 8:29 PM
#3
mshultise avatar

mshultise

Zen Follower

Join Date:
Feb 2005
Location:
Captain Cook, Hawaii
Posts:
172
Plugin Contributions:
0

Re: Hide Disabled Products from "All Products sidebar search"

I believe the WHERE has to be in the SELECT .

This is a 1.5.1 install not an upgrade and I even downloaded the package again to grab the latest file.

I have a disabled product in a disabled category and it shows up in the ALL PRODUCTS with the 1.5.1. file as supplied.

The select being used is:

  • products_all header_php.php
  • @package page
  • @copyright Copyright 2003-2007 Zen Cart Development Team
  • @copyright Portions Copyright 2003 osCommerce
  • @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  • @version $Id: header_php.php 6912 2007-09-02 02:23:45Z drbyte $

.
.

$products_all_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $order_by;

Aloha from Hawaii! (its a dirty job, but SOMEBODY has to live here...)

24 May 2014, 12:37 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Hide Disabled Products from "All Products sidebar search"

OK, this time I read the **title **of your post. What is All Products sidebar search?

The information I gave you (and the code you posted) is from the products_all page which, within an out-of-the-box Zen Cart configuration is accessed by clicking the All Products link that appears within the *Categories *sidebox. I just tested that in an OOTB configuration, disabling the Hardware category results in all sub-categories and products being disabled. No disabled product shows within the products_all page, due to the inclusion of the WHERE p.products_status = 1 clause (which only pulls in products that are enabled).

24 May 2014, 10:32 PM
#5
mshultise avatar

mshultise

Zen Follower

Join Date:
Feb 2005
Location:
Captain Cook, Hawaii
Posts:
172
Plugin Contributions:
0

Re: Hide Disabled Products from "All Products sidebar search"

I solved the problem. Operator error.

Aloha from Hawaii! (its a dirty job, but SOMEBODY has to live here...)