Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    May 2008
    Posts
    402
    Plugin Contributions
    0

    Default Exclude certain categories from new products module?

    Searched all over, can't figure out how to exclude a certain category from showing up in the new product module... the one that displays random products on the homepage or other listing pages.

    I supposed I can go in and modify the "Date Added" for each product in the database, and set the "New Product Listing - Limited to ..." 30 days. BUT this would be a pain, and I would have to do it each time I list a new product in that particular category. There should be an easier way.

    Can someone let me know the key to accomplishing this?

    For example: say your main product is A but you also sell some B. Most of your visitors will be coming to the site looking for A so you don't want all your B showing up randomly in all the product modules. Get it?

  2. #2
    Join Date
    Apr 2004
    Location
    UK
    Posts
    5,821
    Plugin Contributions
    2

    Default Re: Exclude certain categories from new products module?


  3. #3
    Join Date
    May 2008
    Posts
    402
    Plugin Contributions
    0

    Default Re: Exclude certain categories from new products module?

    Quote Originally Posted by misty View Post
    That's a nice start, but I do not want to have to do global replace, since it's not a one time thing. I need to disable the entire category from displaying on the new product module.

    Otherwise, you would need to customize the code to ignore products where master_categories_id = 1313 or what have you ...
    Can someone please explain this more? How would one go about modifying the code to exclude a certain category?

    /index.php?main_page=index&cPath=3_6

  4. #4
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Re: Exclude certain categories from new products module?

    in includes/modules/pages/products_new/header_php.php

    change:

    $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,
    p.master_categories_id
    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:

    $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,
    p.master_categories_id
    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.master_categories_id != CAT-TO-EXCLUDE
    AND pd.language_id = :languageID " . $display_limit . $order_by;

    Make sure to change "CAT-TO-EXCLUDE" to the number of the category you don't want to show up.

  5. #5
    Join Date
    May 2008
    Posts
    402
    Plugin Contributions
    0

    Default Re: Exclude certain categories from new products module?

    Quote Originally Posted by kiddo View Post
    in includes/modules/pages/products_new/header_php.php

    change:
    p.master_categories_id != CAT-TO-EXCLUDE

    Make sure to change "CAT-TO-EXCLUDE" to the number of the category you don't want to show up.
    This is great info and it actually works =)

    BUT it's only working for the "New Products" page. I need the particular category to be eliminated from the New Products module that displays random new products on the home page and other various pages.

  6. #6
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Re: Exclude certain categories from new products module?

    The same can be done elsewhere. For instance if you are using the whats new sidebox and want to not have a category included there look in:

    includes/modules/sideboxes/whats_new.php and find: (about line 19)

    where p.products_id = pd.products_id
    and p.products_status = 1 " . $display_limit;

    and change to:

    where p.products_id = pd.products_id
    and p.master_categories_id != CAT-TO-SKIP
    and p.products_status = 1 " . $display_limit;

    If there are some other place where this category isn't to show, post a link to a page so I can see what you are saying about and I'll point you to where to patch.

    Again, be sure to change CAT-TO-SKIP to the proper category id number.

    Hint: you can exclude more than one category like:

    where p.products_id = pd.products_id
    and p.master_categories_id != CAT-TO-SKIP
    and p.master_categories_id != ANOTHER-CAT-TO-SKIP
    and p.products_status = 1 " . $display_limit;

    or only show new items from one single category like:

    where p.products_id = pd.products_id
    and p.master_categories_id = CAT-TO-SELECT-FROM
    and p.products_status = 1 " . $display_limit;

    Hope that helps some.

  7. #7
    Join Date
    May 2008
    Posts
    402
    Plugin Contributions
    0

    Default Re: Exclude certain categories from new products module?

    GOT IT!

    It works. The file I needed to modify was:
    includes/modules/template/new_products.php

    This effectively removed a particular category from showing up on the main page where the "New Products For (Month)" displays. No need to go into the database to change dates, no need to add fake dates when uploading new products.

    Thanks for your help =)

  8. #8
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Re: Exclude certain categories from new products module?

    Congrats on working it out. That is so much more satisfying!

    Happy Zen Hacking!

  9. #9
    Join Date
    Oct 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Exclude certain categories from new products module?

    I am also trying to prevent a category from showing up on the main page as a new product. This is the code I tried doing on the new_products.php page, but it is not stopping the category from displaying. What am I doing wrong?


    if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
    from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
    where p.products_id = pd.products_id
    and p.master_categories_id != 684
    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
    and p.products_status = 1 " . $display_limit;
    } else {
    // get all products and cPaths in this subcat tree
    $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

    if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
    // build products-list string to insert into SQL query
    foreach($productsInCategory as $key => $value) {
    $list_of_products .= $key . ', ';
    }
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
    p.products_date_added, p.products_price, p.products_type, p.master_categories_id
    from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
    where p.products_id = pd.products_id
    and p.master_categories_id != 684
    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
    and p.products_id in (" . $list_of_products . ")";

  10. #10
    Join Date
    Feb 2010
    Posts
    205
    Plugin Contributions
    0

    Default Re: Exclude certain categories from new products module?

    Hey everyone ... this is exactly what I would like to do.... I have a lot of sheet music and don't want it showing up in the new products window. It is category item# 10 and I've made the modification to the header_php.php file but it is not working. Is there something else I need to enable/disable in my admin to make this work ?

    Thanks for your help.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How to exclude certain products listed in New Products?
    By tifischer in forum General Questions
    Replies: 1
    Last Post: 24 Mar 2014, 09:45 PM
  2. exclude certain products from free shipping
    By emtecmedia in forum Built-in Shipping and Payment Modules
    Replies: 24
    Last Post: 28 Sep 2010, 05:15 PM
  3. Exclude certain categories from spiders
    By Blake81 in forum General Questions
    Replies: 0
    Last Post: 10 Dec 2007, 12:31 PM
  4. Exclude certain products from Paypal option
    By AndyBB in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 30 Aug 2007, 08:09 PM
  5. only display new products from certain categories?
    By hawkeye in forum General Questions
    Replies: 1
    Last Post: 15 May 2007, 05:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR