Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Is there a way to make "Featured Products" show only specific category?

Is there a way to make "Featured Products" show only specific category?

Started by rfree190 on 1 Jul 2013, 2:57 AM · Views: 1,736

Results 1 to 4 of 4
1 Jul 2013, 2:57 AM
#1
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Post #1 by rfree190

Is there a way to only show one category in the "Featured Products" on the main page?

2 Jul 2013, 2:26 AM
#2
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Post #2 by djdavedawson

If you're using the featured products list box on the home page, you can limit it to 1 category by adding this:

AND p.master_categories_id = 89

to

tpl_modules_products_featured_list_box.php

Change 89 to your master category number.

Find this

$featured_products_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,
                                  p.master_categories_id
                                  FROM (" . TABLE_PRODUCTS . " p
                                  LEFT JOIN " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " .
TABLE_PRODUCTS_DESCRIPTION . " pd
                                  LEFT JOIN " . TABLE_FEATURED . " f on pd.products_id = f.products_id )
                                  WHERE p.products_status = 1 and p.products_id = f.products_id and f.status = 1
                                  AND p.products_id = pd.products_id and pd.language_id = :languagesID 
								  ORDER by f.featured_date_available";

Change to this:

$featured_products_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,
                                  p.master_categories_id
                                  FROM (" . TABLE_PRODUCTS . " p
                                  LEFT JOIN " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " .
TABLE_PRODUCTS_DESCRIPTION . " pd
                                  LEFT JOIN " . TABLE_FEATURED . " f on pd.products_id = f.products_id )
                                  WHERE p.products_status = 1 and p.products_id = f.products_id and f.status = 1
                                  [B]AND p.master_categories_id = 89[/B]
                                  AND p.products_id = pd.products_id and pd.language_id = :languagesID 
								  ORDER by f.featured_date_available";

Keep in mind, this will NOT change the featured_products page but WILL change anywhere in the site that uses the featured box.

Another way would be, Since the default is to order them by fettered date, to limit the amount of items that the featured list box shows in the admin, and then set the available dates accordingly to sort them a specific way.

Lets say you have 5 items in that category you want to show, then set the limit to 5 and use the available dates to sort the 5 top the top.

3 Jul 2013, 7:31 PM
#3
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Post #3 by rfree190

Thanks Dave!
My ZC didn't have the file you mentioned, but doing a search, I found the code listed in
/modules/pages/featured_products/header_php.php

Added the code you gave and it seems to have worked.
Do you know if changing the code I changed will cause issues elsewhere on my site?

Thanks again!

3 Jul 2013, 7:51 PM
#4
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Post #4 by djdavedawson

RFree190:

Thanks Dave!
My ZC didn't have the file you mentioned, but doing a search, I found the code listed in
/modules/pages/featured_products/header_php.php

Added the code you gave and it seems to have worked.
Do you know if changing the code I changed will cause issues elsewhere on my site?

Thanks again!

Yes, you're right, I had created a separate template called list box. Sorry about that.

Adding the AND clause will only affect the output of the featured products page and box.

I wanted different results for the page and box so I created an additional template.