Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / Setting Up Categories, Products, Attributes / Excluding 1 Category from New Products

Excluding 1 Category from New Products

Locked

Started by libracorn on 20 Sep 2006, 9:54 PM · Views: 3,143

Results 1 to 20 of 20
This thread is locked. New replies are disabled.
20 Sep 2006, 9:54 PM
#1
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Excluding 1 Category from New Products

Not sure if this is the right forum to ask this....

Is there a way I can exclude one category from appearing in the New Products selection? I have a fund-raising category that I do not want to appear as new products - products that are displayed under NEW on the main page of the store and products that list in the New Products link from the menu.

I was thinking there might be something I could hardcode to exclude the new section from picking up this category.

22 Sep 2006, 12:02 PM
#2
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Anyone? *** bump ***

22 Sep 2006, 7:22 PM
#3
kobra avatar

kobra

Black Belt

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

Re: Excluding 1 Category from New Products

You can adjust this in the DB, but unfortunately this function is by product and not by category. This is done by adjusting the add date back to one that will not be picked up as new.

There also might be a way to code this, but as I am php challenged, this would have to come from another.

Zen-Venom Get Bitten

22 Sep 2006, 8:15 PM
#4
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Yeah... I knew about the added date thing. My problem is there are products added to this category regularly enough that manually editing the dates would be a pain. :(

24 Sep 2006, 1:59 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

When adding to this Category that you want to exclude ... are these Products Linked Products to other categories? Or just belong to 1 Category?

If they are not Linked Products, then you could run a nifty little update on the products table from the Admin ... Tools ... Insert SQL Patches ... to fix the dates of all products where master_categories_id = XX

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Sep 2006, 12:34 PM
#6
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Ah... yes that would work. Not sure how to write the replace statement code though. Could you help me with that?

So for instance, say the master_category is 20, how would the mysql statement syntax be written to replace those dates with 6/1/06?

24 Sep 2006, 1:16 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

If all the products to be excluded are master_categories_id = 20 ... you could add the statement:

AND master_categories_id != 20

To the 2 select statements to exclude them ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Sep 2006, 2:35 PM
#8
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Sorry... I'm not following that exactly. Didn't you say to run some kind of replace sql statement to modify the dates? It sounds like what you just wrote is something I could put in the actual source code for how the new products are pulled from the database. Is that what you meant here? If so, which file would I add this to?

24 Sep 2006, 3:10 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

In /includes/modules/new_products.php are 2 select statements:

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 {
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_date_added,
                                           p.products_price
                           from " . TABLE_PRODUCTS . " p
                           left join " . TABLE_SPECIALS . " s
                           on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  TABLE_CATEGORIES . " c
                           where p.products_id = p2c.products_id
                           and p2c.categories_id = c.categories_id
                           and c.parent_id = '" . (int)$new_products_category_id . "'
                           and p.products_status = 1 " . $display_limit;
}

You need to add another condition to not include the master_categories_id when it is 20 ...

In this case something like:

and p.master_categories_id != 20

to those two statements so that those products with the master_categories_id of 20 are blocked ...

Another way of doing it is to utilize another table, for the products_to_categories but the statement would be more complicated ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Sep 2006, 4:14 PM
#10
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

This should be working... but it's not. It's still displaying the products in that master category.

This is what I have changed it to which looks right... but category 4 products are still displaying in the new products list.

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 and p.master_categories_id != 4" . $display_limit;
} else {
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_date_added,
                                           p.products_price
                           from " . TABLE_PRODUCTS . " p
                           left join " . TABLE_SPECIALS . " s
                           on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  TABLE_CATEGORIES . " c
                           where p.products_id = p2c.products_id
                           and p2c.categories_id = c.categories_id
                           and c.parent_id = '" . (int)$new_products_category_id . "'
                           and p.products_status = 1 and p.master_categories_id != 4" . $display_limit;
}

oh... I also verified in the actual database that the master category ID for the products I'm referring to is 4. I did double check that and in the database it's showing 4 but the products are still in the list.

25 Sep 2006, 2:31 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

Give more "power" to the master_categories_id constraint ...

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 . "
                           and p.master_categories_id != 4)";
} else {
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_date_added,
                                           p.products_price
                           from " . TABLE_PRODUCTS . " p
                           left join " . TABLE_SPECIALS . " s
                           on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
  TABLE_CATEGORIES . " c
                           where (p.products_id = p2c.products_id
                           and p2c.categories_id = c.categories_id
                           and c.parent_id = '" . (int)$new_products_category_id . "'
                           and p.products_status = 1 " . $display_limit . "
                           and p.master_categories_id != 4)";
}

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

25 Sep 2006, 1:43 PM
#12
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Okay... it just occurred to me that maybe we're talking about two different things and that's why I'm not seeing this work how I'm envisioning.

I do not see any category 4 products display in the new section of the homepage of the store... so I'm starting to think the code you have here is for just that section - WHICH IS GREAT! PERFECT!

But... how can I also get category 4 products off the new_products listing? So when someone clicks on the "New Products" link in the actual menu and goes to this page

http://www.site.com/index.php?main_page=products_new

I'd like them not to display there either. Is that possible by adding the same kind exclusion parameter to the file that's used to pull the products new listing?

27 Sep 2006, 2:07 PM
#13
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Is this code also supposed to apply to the New Product Listing page? If not, which file do I modify and add that exclusion parameter to?

Thanks!

1 Oct 2006, 5:09 AM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

That was for the center box ...

For the New Listing ... you need to edit the header_php.php for the /includes/modules/pages/products_new

And for the sidebox you would also need to customize the code ...

You didn't think it was an all for one and one for all did you ... :lamo:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 2:55 PM
#15
lostsheep avatar

lostsheep

Inactive

Join Date:
Aug 2006
Location:
ulaanbaatar
Posts:
94
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

hello
is it so tough simply to delete newly set category by mistake?
can i rename it, or whatever?
tnx

save nature = save water

1 Oct 2006, 3:01 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

I am not sure what you are asking here ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 3:19 PM
#17
lostsheep avatar

lostsheep

Inactive

Join Date:
Aug 2006
Location:
ulaanbaatar
Posts:
94
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

i did it, its ok now
thank u

save nature = save water

1 Oct 2006, 3:24 PM
#18
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Excluding 1 Category from New Products

The X on the right of the screen is the Delete ... this will delete the Category and any Products in the Category ...

If this does not work, then you have an old version of Zen Cart with a bug that has been fixed for sometime since that release ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Oct 2006, 3:29 PM
#19
lostsheep avatar

lostsheep

Inactive

Join Date:
Aug 2006
Location:
ulaanbaatar
Posts:
94
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

thank u linda for promp help

save nature = save water

1 Oct 2006, 9:43 PM
#20
libracorn avatar

libracorn

New Zenner

Join Date:
Jul 2005
Posts:
44
Plugin Contributions:
0

Re: Excluding 1 Category from New Products

Thanks for your help on this Linda! Worked like a charm. :)