Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34
  1. #21
    Join Date
    Feb 2007
    Posts
    10
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    I got a MySQL error when trying the above fix:
    Code:
    1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p.product_is_free != 1 order by p.products_ordered ' at line 10
    in:
    [select distinct p.products_id, pd.products_name, p.products_ordered                              from products p, products_description pd, products_to_categories p2c, categories c                              where p.products_status = '1'                              and p.products_ordered > 0                              and p.products_id = pd.products_id                              and pd.language_id = '1'                              and p.products_id = p2c.products_id                              and p2c.categories_id = c.categories_id                              and '67' in (c.categories_id, c.parent_id) 				     p.product_is_free != 1                              order by p.products_ordered desc, pd.products_name                              limit 20]
    What did I do wrong?

  2. #22
    Join Date
    Feb 2009
    Location
    Melbourne, Australia
    Posts
    85
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    Quote Originally Posted by Ajeh View Post
    Let's say you want to toss out all products in categories_id 42 ...

    That would now use the master_categories_id 42 in the products table so you should be able to use:
    PHP Code:
    $best_sellers_query "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " 
    TABLE_PRODUCTS " p, " TABLE_PRODUCTS_DESCRIPTION " pd
                                 where p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" 
    . (int)$_SESSION['languages_id'] . "'
                                 and p.master_categories_id != 42
                                 order by p.products_ordered desc, pd.products_name
                                 limit " 
    MAX_DISPLAY_BESTSELLERS
    Note: this assumes all products that should not display use the same Category and that Category is "owns" these Products which would reflect that in that the master_categories_id of all of these Products would be the same ...

    In this example:
    PHP Code:
                                 and p.master_categories_id != 42 
    this is the key to the block ...
    Hiya, i was wondering if it is possible to exclude certain products for the bestsellers list? there is 10 of them and they are in different catagories. They where givin as freebies for 3 days before going up for sale and so there for they have taken up all the space on the bestsellers box

  3. #23
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Excluding a product or category from best selling list

    Let's say you didn't want products_id 199 and 26 to show in the Best sellers sidebox ...

    You could customize the best_sellers.php sidebox module with something like:
    Code:
        if (isset($current_category_id) && ($current_category_id > 0)) {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
                                        . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                 and p.products_id = p2c.products_id
                                 and p2c.categories_id = c.categories_id
                                 and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id))
    and p.products_id not in (199, 26)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
    
        } else {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "')
    and p.products_id not in (199, 26)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
        }
    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: v1.5.5]
    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!

  4. #24
    Join Date
    Feb 2009
    Location
    Melbourne, Australia
    Posts
    85
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    Thank you so much for the reply, i will give it a go and post back with a result xoxo

  5. #25
    Join Date
    Feb 2009
    Location
    Melbourne, Australia
    Posts
    85
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    YAYYYYYYYYYYYY ok all fixed thank you ever so much

  6. #26
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Excluding a product or category from best selling list

    You are most welcome ... thanks for the update that this worked for you ...
    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: v1.5.5]
    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!

  7. #27
    Join Date
    May 2007
    Location
    Los Angeles
    Posts
    89
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    Hi Ajeh,
    I followed your directions below and I see no changes to the bestseller sidebox. I did use the override and the products are not free.

    zen 1.3.8

    Thank you for your help!



    Quote Originally Posted by Ajeh View Post
    Let's say you didn't want products_id 199 and 26 to show in the Best sellers sidebox ...

    You could customize the best_sellers.php sidebox module with something like:
    Code:
        if (isset($current_category_id) && ($current_category_id > 0)) {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
                                        . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                 and p.products_id = p2c.products_id
                                 and p2c.categories_id = c.categories_id
                                 and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id))
    and p.products_id not in (199, 26)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
    
        } else {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "')
    and p.products_id not in (199, 26)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
        }

  8. #28
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Excluding a product or category from best selling list

    Check the products_id for the Products that you want to exclude and make sure you have them where you see the 199, 26 ...

    Check that your file actually is updated on the server with these changes in your:
    /includes/modules/sideboxes/your_template_dir/best_sellers.php
    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: v1.5.5]
    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!

  9. #29
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Excluding a product or category from best selling list

    NOTE: there are 2 places in the code for the products_id to be set ...
    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: v1.5.5]
    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!

  10. #30
    Join Date
    May 2007
    Location
    Los Angeles
    Posts
    89
    Plugin Contributions
    0

    Default Re: Excluding a product or category from best selling list

    Ajeh,
    I have uploaded it to the correct folder and made the changes in two section. Below is the complete code. Could it because the categories are under a hidden category? The categories are setup like this:
    Categories / Products - Top > Brand Names (HIDDEN) > Categories (52, 43)

    Thanks a lot!


    Code:
    <?php
    /**
     * best_sellers sidebox - displays selected number of (usu top ten) best selling products
     *
     * @package templateSystem
     * @copyright Copyright 2003-2005 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: best_sellers.php 2718 2005-12-28 06:42:39Z drbyte $
     */
    
    // test if box should display
      $show_best_sellers= false;
    
      if (isset($_GET['products_id'])) {
        if (isset($_SESSION['customer_id'])) {
          $check_query = "select count(*) as count
                          from " . TABLE_CUSTOMERS_INFO . "
                          where customers_info_id = '" . (int)$_SESSION['customer_id'] . "'
                          and global_product_notifications = '1'";
    
          $check = $db->Execute($check_query);
    
          if ($check->fields['count'] > 0) {
            $show_best_sellers= true;
          }
        }
      } else {
        $show_best_sellers= true;
      }
    
      if ($show_best_sellers == true) {
        if (isset($current_category_id) && ($current_category_id > 0)) {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, "
                                        . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                 and p.products_id = p2c.products_id
                                 and p2c.categories_id = c.categories_id
                                 and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id))
    and p.products_id not in (52, 43)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
    
        } else {
          $best_sellers_query = "select distinct p.products_id, pd.products_name, p.products_ordered
                                 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                 where (p.products_status = '1'
                                 and p.products_ordered > 0
                                 and p.products_id = pd.products_id
                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "')
    and p.products_id not in (52, 43)" . "
    
                                 order by p.products_ordered desc, pd.products_name
                                 limit " . MAX_DISPLAY_BESTSELLERS;
    
          $best_sellers = $db->Execute($best_sellers_query);
        }
    
        if ($best_sellers->RecordCount() >= MIN_DISPLAY_BESTSELLERS) {
          $title =  BOX_HEADING_BESTSELLERS;
          $box_id =  'bestsellers';
          $rows = 0;
          while (!$best_sellers->EOF) {
            $rows++;
            $bestsellers_list[$rows]['id'] = $best_sellers->fields['products_id'];
            $bestsellers_list[$rows]['name']  = $best_sellers->fields['products_name'];
            $best_sellers->MoveNext();
          }
    
          $title_link = false;
          require($template->get_template_dir('tpl_best_sellers.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_best_sellers.php');
          $title =  BOX_HEADING_BESTSELLERS;
          require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
        }
      }
    ?>

 

 
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Excluding free items from Best Sellers
    By meljen in forum Customization from the Admin
    Replies: 3
    Last Post: 29 Nov 2012, 03:57 AM
  2. Best selling list for a defines period - is it possible?
    By CaroleAs in forum Basic Configuration
    Replies: 9
    Last Post: 21 Nov 2010, 11:19 PM
  3. Excluding category from search
    By kgeoffrey in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 Jan 2009, 12:46 AM
  4. Excluding sideboxes from product list pages
    By ctcentralinfo in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 11 Jul 2008, 12:56 AM
  5. excluding categories from bestseller list
    By CreativeWitch in forum General Questions
    Replies: 0
    Last Post: 21 Feb 2007, 05:41 PM

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