Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Prevent Stock from one entire Category from appearing on the New Products page

Prevent Stock from one entire Category from appearing on the New Products page

Locked

Started by nigelt74 on 17 Mar 2009, 9:01 PM · Views: 1,282

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
17 Mar 2009, 9:01 PM
#1
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #1 by nigelt74

Version of zencart: 1.3.7 (my server runs php 4.something), so i can't upgrade any higher.
Site has been up and running fine for ages.

Hi all

Basically there is one category from which we don't want any of the subcategories/products to appear on the whats new page,

I can't work out how to prevent this using the admin, so i guess I will have to use an override,

What i am thinking is to utilise a field that i don't use in the product listing, in this case MODEL and I will add a key word in there if i don't want the product to show up on the New Products page, the keyword would be "HIDE", so i would then alter the New Products query to add something like
where model != "HIDE" ---- (is that how you write not equal in mysql), sorry have a toddler helping me type and I can't think straight
But I can't find the query for the "new products" page

Things I have already ruled out
ALTERING THE DATE IN THE DATABASE IS NOT SUITABLE IN THIS SITUATION AS WE WANT THE CORRECT ADDED DATE displayed
Using the parent category number in the query to block it - we have subcategories within subcategories and not all the products are at the same level if you get my meaning so we would have to add all the subcategories to an exclusion list (and there are regularly more added), or we have to do a subqueries to get the parent of the parent etc

Any help would be greatly appreciated

Webzings Design
Semi retired from Web Design

17 Mar 2009, 10:18 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

Site has been up and running fine for ages.
If the products in this cat have an older "date added"

In the admin
admin > config > maximum values > New Product Listing - Limited to ... > select a date range

Zen-Venom Get Bitten

17 Mar 2009, 11:11 PM
#3
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #3 by nigelt74

kobra:

If the products in this cat have an older "date added"

In the admin
admin > config > maximum values > New Product Listing - Limited to ... > select a date range

Can't do that as both the category i wish to exclude and the other categories are having products added to them all the time

Webzings Design
Semi retired from Web Design

17 Mar 2009, 11:27 PM
#4
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #4 by nigelt74

Ok no worries got it working, I think
I edited the code on includes/modules/pages/product_new/header_php.php

  $products_new_query_raw = "SELECT p.products_id, p.products_type, 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
                             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 " . $display_limit . $order_by;

to add AND p.products_model != 'HIDE'

  $products_new_query_raw = "SELECT p.products_id, p.products_type, 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
                             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 p.products_model != 'HIDE'
                             AND pd.language_id = :languageID " . $display_limit . $order_by;

and it seems to work

Edit: Can I do this as an override rather than using the original page as i don't see a classic folder in this directory?

Webzings Design
Semi retired from Web Design

18 Mar 2009, 1:43 AM
#5
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #5 by nigelt74

Also thought I should add this just in case anyone else is wanting to do something similar

The above will stop those products appearing on your "New Products" Page

However it will not prevent the products appearing in the "New Products for Month" section of your page, *if you have this turned on
*

As the category that I wanted to hide the products of, was a top level category, these product were also appearing on my main page in the "New Products for Month" section to prevent this I changed this

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  $new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_date_added
                           from " . TABLE_PRODUCTS . " p
                           where p.products_status = 1 " . $display_limit;
} else {

to this

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  $new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_model, p.products_price, p.products_date_added
                           from " . TABLE_PRODUCTS . " p
                           where p.products_model != 'HIDE'
                           and p.products_status = 1 " . $display_limit;
} else {

on the includes/modules/pages/new_products.php file (around line 18)
and saved the file as
on the includes/modules/pages/my_template/new_products.php where my_template is the name of your template

edit: remember I am using version 1.3.7

By doing it this way the "hidden" products won't ever appear on the main page in the "New Products for Month" heading, but they will still appear under that heading when i am inside the category that contains them.

Cheers

Webzings Design
Semi retired from Web Design