Forums / Customization from the Admin / How to limit Random display on main page to 1 category?

How to limit Random display on main page to 1 category?

Locked

Started by dreamdaily on 29 Jun 2006, 1:14 AM · Views: 2,936

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
29 Jun 2006, 1:14 AM
#1
dreamdaily avatar

dreamdaily

New Zenner

Join Date:
Apr 2005
Posts:
53
Plugin Contributions:
0

How to limit Random display on main page to 1 category?

Hello,

The main page by default displays in a tabular format random selection from all categories in the store.
This is perfect for my store, however, I would like to limit the random display to products from only one category.

How can I do that?

or

as an alternative solution: how do I prevent Gift Certificates from showing up in the random selection on the main page?

Thank you,
dreamdaily

29 Jun 2006, 4:19 AM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: How to limit Random display on main page to 1 category?

To make the change to the new products set on the main page, edit includes/modules/new_products.php and when done, save it as includes/modules/your_template/new_products.php.

Find this section of code:

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 {

and add a restriction to the category.
To limit the selections to a single category, modify that code 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_price, p.products_date_added
                           from " . TABLE_PRODUCTS . " p
                           where p.products_status = 1 
						   and p.master_categories_id = xx " . $display_limit;
} else {
``` where xx is the category id number of the category you want to select from.
To simply remove the gift certificates from the selection, change the code to this:
```php
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 <> yy " . $display_limit;
} else {
``` where yy is the category id number of your gift certificates category.

Similar changes can be made for featured products and specials by editing the module files featured_products.php and specials_index.php in the same way and saving them as overide copies.

Neville
An assumption is what you arrive at when you get tired of thinking...

29 Jun 2006, 2:16 PM
#3
dreamdaily avatar

dreamdaily

New Zenner

Join Date:
Apr 2005
Posts:
53
Plugin Contributions:
0

Re: How to limit Random display on main page to 1 category?

Thank you, Super Bunny!

13 Feb 2009, 2:36 AM
#4
flower avatar

flower

New Zenner

Join Date:
Dec 2008
Posts:
36
Plugin Contributions:
0

Re: How to limit Random display on main page to 1 category?

BonyIp,

the same question but for Zen Cart 1.38a.

The text in the program is slightly different.

Thanks