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?
Started by rfree190 on 1 Jul 2013, 2:57 AM · Views: 1,736
Zen Follower
Is there a way to only show one category in the "Featured Products" on the main page?
Zen Follower
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.
Zen Follower
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!
Zen Follower
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.phpAdded 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.
Tell staff why this post should be reviewed.